mirror of
https://github.com/php/php-src.git
synced 2026-04-27 18:23:26 +02:00
7566742754
openssl_pkey_new() fetches various options from the config file -- most of these are optional, and not specifying them is not an error condition from the perspective of the user. Unfortunately, the CONF_get_string() API pushes an error when accessing a key that doesn't exist (_CONF_get_string does not, but that is presumably a private API). This commit adds a helper php_openssl_conf_get_string() that automatically clears the error in this case. I've found that OpenSSL occasionally does the same thing internally: https://github.com/openssl/openssl/blob/22040fb790c854cefb04bed98ed38ea6357daf83/apps/req.c#L515-L517 Closes GH-6699.
24 lines
433 B
PHP
24 lines
433 B
PHP
--TEST--
|
|
Bug #80747: Providing RSA key size < 512 generates key that crash PHP
|
|
--FILE--
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded("openssl")) die("skip");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
$conf = array(
|
|
'config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf',
|
|
'private_key_bits' => 511,
|
|
);
|
|
var_dump(openssl_pkey_new($conf));
|
|
while ($e = openssl_error_string()) {
|
|
echo $e, "\n";
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
bool(false)
|
|
error:%s:key size too small
|