Category : openssl

I have installed SSL on mac os using the following commands sudo openssl genrsa -out ~/.localhost-ssl/localhost.key 2048 sudo openssl req -new -x509 -key ~/.localhost-ssl/localhost.key -out ~/.localhost-ssl/localhost.crt -days 3650 -subj /CN=localhost sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.localhost-ssl/localhost.crt After installing this SSL I have configured my httpd/apache with these certificates and keychains. Then https://localhost ..

Read more

function encrypt($string) { $key = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAIiJg//yXqt7ln+orfSuRjH0FjTKQyj6ti2tX8PR8yhvoeocfHg0RtBNBJFaghoezGgbsmsUcac8GSgoiL9kzzMCAwEAAQ=="; $keyFinal = "—–BEGIN PUBLIC KEY—–rn" . chunk_split($key) . "rn—–END PUBLIC KEY—–"; openssl_public_encrypt($string, $encrypted_data, $keyFinal); echo base64_encode($encrypted_data); } (Every other key I try gives the same error, too) am trying to encrypt a string using rsa but i get an error (openssl_public_encrypt(): key parameter is not a valid public key) ..

Read more

Problem Statement I’m trying to decrypt data using private_key from PKCS12 formatted file by openssl_private_decrypt(). However I’m getting empty string in response. Exception [ 0 => "error:0909006C:PEM routines:get_name:no start line" 1 => "error:0406506C:rsa routines:rsa_ossl_private_decrypt:data greater than mod len" ] Files & Configuration $pkcs12 = file_get_contents($this->pkcs12); openssl_pkcs12_read($pkcs12, $p12, ‘123456’); if (false === openssl_private_decrypt($encrypted, $decrypted, $p12[‘pkey’], OPENSSL_PKCS1_PADDING)) ..

Read more

Problem Statement I’m trying to decrypt data using private_key from PKCS12 formatted file by openssl_private_decrypt(). However I’m getting empty string in response. Exception [ 0 => "error:0909006C:PEM routines:get_name:no start line" 1 => "error:0407109F:rsa routines:RSA_padding_check_PKCS1_type_2:pkcs decoding error" 2 => "error:04065072:rsa routines:rsa_ossl_private_decrypt:padding check failed" ] Files & Configuration $pkcs12 = file_get_contents(‘/path/server.p12’); openssl_pkcs12_read($pkcs12, $p12, ‘123456’); if (false === ..

Read more