Forum Moderators: coopster
We use openssl to encrypt/decrypt some data and login info for 2 years now. And now the script has stoped working.
The script works fine in existing users/accounts, but fails when we create new accounts.
My knowledge on ecryptions is rather limited (non-existant i would say).
So, reading the script line by line and with the manual open to the openssl functions here are my notes:
Following is the ines the script fails when a new user/account is created.
The $cfg is only used in creating the unique key for the user and it is empty.
$cfg = &$GLOBALS['c_ossl_cfg'];
$rpkey = openssl_pkey_new($cfg);
if(!$rpkey) return false;
According to manual: openssl_pkey_new ( [array configargs] )
So, this can be empty and function will use the defualt options from the openssl.cnf.
So i create a nerw simple script with only 1 line of code: $rpkey = openssl_pkey_new();
Yet this also returned false.
Next step.. phpinfo() to check the openssl:
OpenSSL support enabled
OpenSSL Version OpenSSL 0.9.8c
And i ran out of ideas... openssl seems to be ok
Yet the function returns an error...
Can anyone provide any feedback on what to look/check?
The people on the server say that nothing has changed in the last months - yet with this kind of an error i hardy believe them, but i cannot prove anything :(
$publickey='';
$privatekey='';
$phrase= '999999999999999999999999999999';$csa = array(
'countryName'=>'GR',
'stateOrProvinceName'=>'Attika',
'localityName'=>'Athens',
'organizationName'=>'example.com',
'organizationalUnitName'=>'Some Department',
'commonName'=>'secure.example.com',
'emailAddress'=>'webmaster@example.com'
);
$rpkey = openssl_pkey_new();
if(!$rpkey) { echo 'ERROR in "rpkey" creation<br>'; exit(); }
$csr = openssl_csr_new($csa,$rpkey);
$rcert = openssl_csr_sign($csr,NULL,$rpkey,365);
openssl_x509_export($rcert,$publickey); // get $publickey
$rv = openssl_pkey_export($rpkey,$privatekey,$phrase); // get $privatekey
if(!$rv) { echo 'ERROR in "rv" creation<br>'; exit(); }
$keys = array('public'=>$publickey,'private'=>$privatekey);
echo "<pre>";
print_r($keys);