xenador xenador -5 years ago 371
PHP Question

xampp openssl errors when calling openssl_pkey_new();

so I am trying to get openssl working on my windows installation of xampp(1.7.3) which is built with OpenSSL 0.9.8l. This is only my second time to install openssl on an *amp install but the first time went swimmingly(it was a wamp install on the same machine, but I found that xampp was more my style so I switched).

when I attempted a simple setup script:

$privateKey = openssl_pkey_new();

while($message = openssl_error_string()){
echo $message.'<br />'.PHP_EOL;

I got a returned message:

error:02001003:system library:fopen:No such process
error:2006D080:BIO routines:BIO_new_file:no such file
error:0E064002:configuration file routines:CONF_load:system lib

I read the php.net page that informed me about the possibility of needing to set the openssl.cnf and ssleay.dll environment constants, I tried that but nothing changed.

resulted in the path:
which is correct for my machine.

I checked that the path to the php directory (where ssleay32.dll and libeay32.dll are located) was defined in my path system var, and it was not, so I defined it, restarted my machine, and in the process rebooted apache, but no change in the error messages.

my version of xampp did not come with a php_openssl.dll and as such I believe the php.ini document should exclude it from the list of available .dlls as it did when I checked. I believe xampp comes compiles with a zend based extension instead.

I am able to start openssl from the xampp gui, and I sucessfully created a private/public key pair.

phpinfo() reports:

openssl OpenSSL support enabled

OpenSSL Library Version OpenSSL

0.9.8l 5 Nov 2009 OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009

there was an old ssleay.dll and libeay32.dll from the wamp install I presume in my systems directory but I have deleted them since. (restarted after, and rebooted apache)

I tried copying the openssl.cnf to the default directory'C:\usr\local\ssl\openssl.cnf' no change.

I also read this thread and this thread but the answers given were relevant but failed to help or were non-existant.

Anyone have any ideas on what I should check next or anything obvious that I missed?

Answer Source

Maybe you need to specify the path to your openssl.cnf file when calling openssl_pkey_new():

$configArgs = array(
    'config' => '/etc/openssl/openssl.cnf',
    // ...

You may also need to specify additional settings in $configArgs for the function to work (have not tested that lately). See also http://php.net/manual/en/function.openssl-csr-new.php for a description of supported further configuration arguments.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download