How to configure xampp to accept the openssl_pkey_new command?

0

I'm trying to use the openssl_pkey_new command, it was working fine in wamp, but when using xampp it stopped.

The code looks like this:

$sslConfig = array(
    "digest_alg" => "sha512",
    "private_key_bits" => 2048,
    "private_key_type" => OPENSSL_KEYTYPE_RSA            
);

$privkey = openssl_pkey_new($sslConfig);

The error you are experiencing is this:

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

All the searches I've done have pointed out that the error is in the openssl.cnf file, but I've tried everything to work and so far I have not got a positive result just the same error above.

I seted the file path in httpd-xampp.conf, all that I found in the xampp folder, I also tried what I had in the wamp folder, I tried to install openssl on windows and set up openssl.cnf, and also did not work (I tried putting openssl in the environment variables just for "disengagement of consciousness").

I tried to add the path also using the config in php itself, like this:

$sslConfig = array(
    "config" => 'C:\xampp\htdocs\Carteira\openssl.cnf',
    "digest_alg" => "sha512",
    "private_key_bits" => $tamanho,
    "private_key_type" => OPENSSL_KEYTYPE_RSA            
);

And the result remains the same, when you start the command getenv ('OPENSSL_CONF') shows the path I set up in httpd-xampp.conf, whether or not you put it in $ sslConfig:

C:\xampp\htdocs\Carteira\openssl.cnf

I checked if the path was correct several times, I even used the file_exists command, to be 100% certain, and yes the path is right, it returns 1.

echo file_exists(getenv('OPENSSL_CONF'));
    
asked by anonymous 14.10.2017 / 22:03

1 answer

0

I wanted to use xampp because I liked its performance, I found it faster and easier to configure compared to the wamp, but I gave up and went back to the wamp, because throughout the project I used it and had no problem.

Actually in the xampp the openssl_pkey_new command was not working, then through searches find out this command:

while ($msg = openssl_error_string())
    echo $msg . "<br />\n";

This is to show the errors of openssl, but when installing wamp again and running the application, I come across the same error found in xampp (I did not previously use the openssl_error_string command in wamp, since I had no problems using the openssl no wamp):

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

I found it strange, since I did the same procedures of the last installation, so when searching for a little more, find out that the openssl_error_string command should not be used this way, within a while, and this way:

$privkey = openssl_pkey_new($sslConfig);
openssl_error_string();

That is, the command and just below openssl_error_string (), so it captures the error of that execution, using while it will generate error, since it could not catch any "second" execution.

Then it is possible that when setting the correct path of openssl.cnf or putting the path in config, the problem has been solved, but now I am using the wamp again, so I can not say.

    
16.10.2017 / 12:33