9

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?

Community
  • 1
  • 1
xenador
  • 211
  • 4
  • 15
  • Its interesting `OPENSSL_CONF` is `C:/xampp/apache/bin/openssl.cnf`, which is well configured. The only minor nit is Windows uses back slashes, not forward slashes. – jww Jun 11 '16 at 22:40

2 Answers2

14

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.

Arc
  • 11,143
  • 4
  • 52
  • 75
  • 1
    ok I can give it a try, I thought that the function should look for the openssl.cnf file based on the routing specified on http://www.php.net/manual/en/openssl.installation.php, but maybe it doesnt have access to the environment var? – xenador Jan 19 '11 at 18:17
  • where is the location of openssl.cnf – user4951 Dec 18 '12 at 10:36
  • It depends on your OpenSSL installation. If you use OpenSSL from a Linux system with package management, it may be in `/etc/openssl/` as in the example. You may find a web server environment variable `$_SERVER['OPENSSL_CONF']` that gives you the location. – Arc Dec 19 '12 at 10:35
  • 1
    Worked for me only after I set explicitly $configArgs['config'] to getenv('OPENSSL_CONF'). It seems that openssl_pkey_new is ignoring the env variable and requires you set the configuration explicitly. – fernacolo Apr 10 '14 at 05:44
4

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

Simon
  • 41
  • 1