Closed FabulousGee closed 5 years ago
Since this seems to be a configuration issue regarding OpenSSL, we just should add some more information on what is going on... I raised a PR ( https://github.com/yourivw/LEClient/pull/36 ) for this, feel free to modify.
And I added another PR ( https://github.com/yourivw/LEClient/pull/37 ) to have full coverage.
I resolved the error by overriding the openssl config path manually. You might consider to implement this in a generic way, too. For reference, this is what my code looks like after the both PR (see above) and the modification of the config array:
$config = array( "private_key_type" => OPENSSL_KEYTYPE_RSA, "private_key_bits" => intval($keySize), "config" => "/php/extras/ssl/openssl.cnf" ); $res = openssl_pkey_new($config); if ($res === false) { $error = "Could not generate key pair! Check your OpenSSL configuration. OpenSSL Error: ".PHP_EOL; while($message = openssl_error_string()){ $error .= $message.PHP_EOL; } throw new \RuntimeException($error); } if(!openssl_pkey_export($res, $privateKey, NULL, $config)) { $error = "RSA keypair export failed!! Error: ".PHP_EOL; while($message = openssl_error_string()){ $error .= $message.PHP_EOL; } throw new \RuntimeException($error); }
Tried to run the example on Windows with nginx+PHP-FastCGI. If you need more information, let me know.