Configuring for OpenSSL

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Configuring for OpenSSL

Postby dwlamb » 26. July 2011 16:11

I am using the full version of xampp 1.7.4 with PHP 5.3.5 and having a challenge with openssl.

The openssl extension is enabled in php.ini and php_openssl.dll is present in xampp\php\ext\.

In the course of writing and testing a function to decrypt data using openssl_pkey_get_private I receive the following:

Warning: openssl_private_decrypt() [function.openssl-private-decrypt]: key parameter is not a valid private key in ...<line number in source code>

After much hair pulling as to the error, I ran a simple test:

Code: Select all
="<has value in source>";
$priv_key_file_name = ("private.pem");

if (openssl_pkey_get_private(array("file://$priv_key_file_name", $passphrase)))
        print "\nPrivate Key OK\n\n";
 else {
        print "\nPrivate key NOT OK\n\n";

The test failed on my local machine for development but succeeded on the actual server I intend to publish this application to. Next, I tried running my application on the same host server. It works perfectly. Something is wrong with PHP on my XAMPP installation. It is odd for I can encrypt without a problem.

Here is my function

Code: Select all

= ("private.pem");
$phrase = "<has value in source>";
function decrypt ($encrypted, $priv_key_file_name, $phrase) {
    $private_key = openssl_pkey_get_private(array("file://$priv_key_file_name", $phrase));
    $encryptedData =  base64_decode($encrypted);
    $data = '';
    openssl_private_decrypt($encryptedData, $data, $private_key);
    return $data;

In debugging, $private_key comes up empty on an echo and FALSE in my IDE with Xdebug.

There is still a lot to do on this and it would be better if I can continue my development under XAMPP rather than uploading to and testing on the production server.

Any ideas?
Posts: 3
Joined: 20. August 2010 22:17

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 91 guests