yourivw / LEClient

An easy-to-use PHP ACME v2 client library, designed to be used with LetsEncrypt.
MIT License
204 stars 98 forks source link

LEClient not working on Windows #85

Closed leo-unglaub closed 4 years ago

leo-unglaub commented 4 years ago

Hey, first of all, i love your library. Great job and thanks for providing it on Github. I am trying to run it on Windows and i get the following error message:

$c = new LEClient\LEClient('foo@foobar.com', true);
RuntimeException with message 'Could not generate key pair! Check your OpenSSL configuration. OpenSSL Error: 
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
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
'

Any ideas why that happens? Thanks and greetings Leo

yourivw commented 4 years ago

Have you managed to find a solution yet? I would guess there's a problem with your OPENSSL configuration file, or this is not missing. Have a look at this thread on stackexchange: https://stackoverflow.com/questions/4719939/xampp-openssl-errors-when-calling-openssl-pkey-new

Maybe it has something to do with OPENSSL_CONF variable in Windows or in XAMPP if you use that one. I do use XAMPP on Windows 10 and it works for me.

leo-unglaub commented 4 years ago

I managed to set the config option for every openssl_pkey_new() call in your library but now i get a different error message:

LEClient/Exceptions/LEFunctionsException with message 'RSA keypair export failed!! Error: 
error:0E064002:configuration file routines:CONF_load:system lib
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:2406F079:random number generator:RAND_load_file:Cannot open file
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
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 dont have XAMPP installed, it just have downloaded PHP from https://windows.php.net/ and unpacked it. Usually this works fine. But maybe i am missing something here.

2020-04-05 19_57_31-PHP 7 4 1 - phpinfo() - Firefox Developer Edition

yourivw commented 4 years ago

This Openssl default config file, openssl.cnf, have you checked this file? Does it actually exist? And have you tried replacing it with a new config file?

There should be no need to change anything in the code.

leo-unglaub commented 4 years ago

Yes, that file exists. I had to create it and copy the default file to that location because that path is set during compile time an cannot be changed with a config clag. But i have to admid, your code is correct. This is not something that you have to fix, that is clearly an OpenSSL problem.

Thanks anyway!

yourivw commented 4 years ago

Have a look here too about the cnf file: https://www.php.net/manual/en/openssl.installation.php In the note (Note: Note to Win32 Users) you will see some information about where PHP will find the config file. The first one is the OPENSSL_CONF environmental variable. This you can set in the Windows environment variables. This one should also show in phpinfo(), see my configuration:

image