Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

var_dump(getenv('OPENSSL_CONF'));
$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.

A var_dump of OPENSSL_CONF resulted in the path: C:/xampp/apache/bin/openssl.cnf 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?

like image 307
xenador Avatar asked Jan 18 '11 02:01

xenador


2 Answers

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

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

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.

like image 168
Arc Avatar answered Oct 21 '22 14:10

Arc


You check the OPENSSL_CONF variable in xampp/apache/conf/extra/http-xampp.conf

Then start apache using the xampp/apache_start.bat NOT THE XAMPP CONTROL PANEL (its strange that when started from the control panel it doesn't work [maybe a current directory problem])

This is for XAMPP 1.7.4 on Win7 64bit

like image 4
Simon Avatar answered Oct 21 '22 16:10

Simon