Skip to content
Advertisement

OpenSSL not working on Windows, errors 0x02001003 0x2006D080 0x0E064002

Problem: OpenSSL is not working in my Windows environment. OpenSSL repeatedly reports errors 0x02001003, 0x2006D080 and 0x0E064002.

Environment:

JavaScript

What I’ve Attempted:

  • Installation Instructions http://www.php.net/manual/en/openssl.installation.php
  • PHP.ini extension=php_openssl.dll
  • Openssl.cnf E:wampphpextrasopenssl.cnf
  • %PATH% E:wampphp
  • Rebooted
  • phpinfo:
    —-OpenSSL support enabled
    —-OpenSSL Library Version OpenSSL 1.0.1e 11 Feb 2013
    —-OpenSSL Header Version OpenSSL 0.9.8y 5 Feb 2013
  • With and without specifying config in configargs
  • With and without specifying <Directory E:wampphpextras> in apache config
  • Copied openssl.cnf to virtualhost public_html, pointed to that and still get same errors
  • Nothing logged in error_log
  • Researched: I’ve spent the last 2 days researching this, surprised there isn’t more info on it so I’m posting here. Seems to be problem with OpenSSL config or apache/php not reading config properly.

Code:

JavaScript

Results:

JavaScript

OpenSSL Manually:

JavaScript

EDIT:

  1. Thanks to @Gordon I can now see open_ssl errors using openssl_error_string
  2. Completely uninstall EasyPHP. Manually installed stable versions of PHP/Apache. Same results! Definitely something I’m doing wrong with implementing openssl on windows.
  3. OpenSSL Manually section… additional error info

FINAL THOUGHTS:
I set up a linux box and I’m getting the same errors. After some playing around I see that even though it’s throwing errors at the openssl_pkey_new it does eventually create my test p12 file. Long story short, the errors are misleading and it has to deal more with how you are using openssl functions not so much server-side configuration.

Final code:

JavaScript

Close away.

A year later…

So I found myself doing this again a year later, and regardless of whatever PATH variables I set on the computer or during the script execution, it kept erroring about file not found. I was able to resolve it by passing in the config parameter in the config_args array in openssl_pkey_new. Here is a function that tests the ability to successfully use OpenSSL:

JavaScript

Advertisement

Answer

The code below works as expected. BUT if you run openssl_error_string() after the openssl methods it shows error:0E06D06C:configuration file routines:NCONF_get_string:no value which is some notice I have not been able to find documentation on.

Further note that according to http://www.php.net/manual/en/function.openssl-error-string.php you could be seeing mis-leading errors as error messages are queued:

Be careful when using this function to check errors, as it seems to read from a buffer of > errors, which could include errors from another script or process that was using openssl > functions. (I was surprised to find it returing error messages before I had called any > openssl_* functions)

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement