OpenSSL not working on Windows, errors 0x02001003 0x2006D080 0x0E064002
The code below works as expected. BUT if you run openssl_error_string()
after the openssl methods it shows error:0E06D06C:configuration file routines:NCONF_get_string:no value
which is some notice I have not been able to find documentation on.
Further note that according to http://www.php.net/manual/en/function.openssl-error-string.php you could be seeing mis-leading errors as error messages are queued:
Be careful when using this function to check errors, as it seems to read from a buffer of > errors, which could include errors from another script or process that was using openssl > functions. (I was surprised to find it returing error messages before I had called any > openssl_* functions)
<?php
/* Create the private and public key */
$res = openssl_pkey_new();
openssl_error_string(); // May throw error even though its working fine!
/* Extract the private key from $res to $privKey */
openssl_pkey_export($res, $privKey);
openssl_error_string(); // May throw error even though its working fine!
/* Extract the public key from $res to $pubKey */
$pubKey = openssl_pkey_get_details($res);
$pubKey = $pubKey["key"];
$data = 'i.amniels.com is a great website!';
/* Encrypt the data using the public key
* The encrypted data is stored in $encrypted */
openssl_public_encrypt($data, $encrypted, $pubKey);
/* Decrypt the data using the private key and store the
* result in $decrypted. */
openssl_private_decrypt($encrypted, $decrypted, $privKey);
echo $decrypted;
?>
OpenSSL not working on Windows, errors 0x02001003 0x2006D080 0x0E064002
The code below works as expected. BUT if you run openssl_error_string()
after the openssl methods it shows error:0E06D06C:configuration file routines:NCONF_get_string:no value
which is some notice I have not been able to find documentation on.
Further note that according to http://www.php.net/manual/en/function.openssl-error-string.php you could be seeing mis-leading errors as error messages are queued:
Be careful when using this function to check errors, as it seems to read from a buffer of > errors, which could include errors from another script or process that was using openssl > functions. (I was surprised to find it returing error messages before I had called any > openssl_* functions)
<?php
/* Create the private and public key */
$res = openssl_pkey_new();
openssl_error_string(); // May throw error even though its working fine!
/* Extract the private key from $res to $privKey */
openssl_pkey_export($res, $privKey);
openssl_error_string(); // May throw error even though its working fine!
/* Extract the public key from $res to $pubKey */
$pubKey = openssl_pkey_get_details($res);
$pubKey = $pubKey["key"];
$data = 'i.amniels.com is a great website!';
/* Encrypt the data using the public key
* The encrypted data is stored in $encrypted */
openssl_public_encrypt($data, $encrypted, $pubKey);
/* Decrypt the data using the private key and store the
* result in $decrypted. */
openssl_private_decrypt($encrypted, $decrypted, $privKey);
echo $decrypted;
?>
OpenSSL error 0x2006D002 when creating CSR
Solved, I need specify $keyConfig for OpenSSL function :
$keyConfig = array(
'config' => dirname($_SERVER['SCRIPT_FILENAME']) . '/store/openssl.cnf',
...
);
$sslConfig = array(
"countryName" => 'XX',
"stateOrProvinceName" => 'XX',
"localityName" => 'XX',
...
);
$pKey = openssl_pkey_new( $keyConfig );
$pCSR = openssl_csr_new( $sslConfig, $pKey , $keyConfig );
$pCRT = openssl_csr_sign( $pCSR , null , $pKey , self::TIME_INTERVAL_WEEK , $keyConfig );
openssl_x509_export( $pCRT, $strCertificate );
openssl_pkey_export( $pKey, $strPrivateKey , null , $keyConfig );
OpenSSL installed but not working
You need to upgrade PHP to version >= 5.3.
mod_fcgi with huge number of errors
I have found today that parallels offer a solution for this issue since May 2012:
http://kb.parallels.com/en/113418
Related Topics
Php: How to Generate a Hmacsha256 Signature of a String
How to Convert All Characters to Their HTML Entity Equivalent Using PHP
PHP Call Class Function by String Name
Get "Content-Type" Header of Request in PHP
Mailgun Sent Mail with Attachment
Uncompress a Gzip File from Curl, on PHP
Removing Black Borders 4:3 on Youtube Thumbnails
PHP Date Time Current Time Add Minutes
Error_Reporting(E_All) Does Not Produce an Error
Alternative to Money_Format() Function
How to Show Ajax Loading Gif Animation While the Page Is Loading