openssl-pkey-export-and-cannot-get-key-from-parameter-1
Warning: openssl_pkey_export(): Cannot get key from parameter 1 in C:\laragon\www\encrypt-and-decrypt-using-open-ssl-in-php\rsagen.php on line 4
Fatal error: Uncaught TypeError: openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given in C:\laragon\www\encrypt-and-decrypt-using-open-ssl-in-php\rsagen.php:6 Stack trace: #0 C:\laragon\www\encrypt-and-decrypt-using-open-ssl-in-php\rsagen.php(6): openssl_pkey_get_details(false) #1 {main} thrown in C:\laragon\www\encrypt-and-decrypt-using-open-ssl-in-php\rsagen.php on line 6
My code is here
$res = openssl_pkey_new();
openssl_pkey_export($res, $privkey, "PassPhrase number 1"); {
// Get details of public key
$pubkey = openssl_pkey_get_details($res);
$pubkey = $pubkey["key"];
$rsaKey = openssl_pkey_new(array(
'private_key_bits' => 4096,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
));
$privKey = openssl_pkey_get_private($rsaKey);
openssl_pkey_export($privKey, $pem);
Solution
Click on the START button
Click on CONTROL PANEL
Click on SYSTEM AND SECURITY
Click on SYSTEM
Click on ADVANCED SYSTEM SETTINGS
Click on ENVIRONMENT VARIABLES
Under "System Variables" click on "NEW"
Enter the "Variable name" OPENSSL_CONF
Enter the "Variable value". My is - C:\wamp\bin\apache\Apache2.2.17\conf\openssl.cnf
Click "OK" and close all the windows and RESTART your computer.
then press ok
then start restart system
Top comments (0)