(This question was originally posted on ServerFault - I have deleted it there and moved it here.)
I have a development machine running PHP 5.3.5 and a produ
You passed the wrong parameter of openssl_public_encrypt
openssl_public_encrypt($data, $encrypted_data, $key1, OPENSSL_PKCS1_PADDING)
where $key1
is the resource id use $key
instead of $key1
. You can use
openssl_public_encrypt($data, $encrypted_data, $key, OPENSSL_PKCS1_PADDING)
According to this post, the issue is related to different OpenSSL versions of Apache and PHP in the XAMPP/Windows installation. I had a similar issue with openssl_verify. I solved it by using the same OpenSSL version for both Apache and PHP (replacing DLLs). Here's a link to the solution.
"I found a solution for the problem, it seems there are 2 wrong files in /apache/bin/ in the default 1.7.7 installation that need to be replaced by the files existing in /php/ (libeay32.ddl and ssleay32.dll)"