How to configure xampp to accept the openssl_pkey_new command?

Asked

Viewed 167 times

0

I’m trying to use the openssl_pkey_new command, it was working very well on wamp, but when using xampp it stopped.

The code is like this:

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

$privkey = openssl_pkey_new($sslConfig);

The error that this presenting 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 did pointed out that the error is in openssl.cnf file, but I’ve tried everything to work and so far did not get a positive result just the same above error.

I set the file path in httpd-xampp.conf, all I found in the xampp folder, I also tried what I had in wamp folder, I even tried to install openssl in windows and set the openssl.cnf from it and it also didn’t work(I even tried to put openssl in the environment variables just to "consciousness-raising").

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

$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 by printing the getenv('OPENSSL_CONF') command shows the path I configured in httpd-xampp.conf, whether or not I put it in $sslConfig:

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

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

echo file_exists(getenv('OPENSSL_CONF'));

1 answer

0


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

In fact in xampp the openssl_pkey_new command was not working, so through searches discover this command:

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

It serves to show openssl errors, 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 on wamp, as I had no problems using openssl on 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 a little more, discover that the openssl_error_string command should not be used this way, inside a while and yes this way:

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

That is the command and just below the 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.

So it’s possible that by setting the correct path to openssl.cnf or by setting the path to config, the problem has been solved, but now I’m using wamp again, so I can’t say.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.