-
Notifications
You must be signed in to change notification settings - Fork 7.9k
openssl_pkey_new function is not working in the PHP version above 8.2+ #13214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
PHP 8.2 switched to OpenSSL 3.0 so you might need to add some extra setting to enable unsecure algorithms or change your app. It's most likely due to using md5 as digest key which you should not be using in the first place. If you really really need to use, then you might try to lower security level in your openssl.cnf. You can also try to enable legacy provider if that doesn't work like described in #12369 but don't think it's needed for md5 digest alg. |
I set it to feedback as there is not much on our side to do but if you still feel, there's some other issue, please comment here. |
I am using OpenSSL 3.2 which is latest so I don't think this solution work |
Have you tried to lower security level in your openssl.cnf? |
New OpenSSL versions have higher security level so it does not allow some algorithm. In addition some old algorithms have been moved to legacy provider which must be explicitly enabled to be able to use them. |
I assume you are not using PHP provided binaries if you are using OpenSSL 3.2, right? |
Hope the below details will help you understand the details. $key = openssl_pkey_new([ So I tested multiple things and found openssl_pkey_new function is not working properly. Hope this many details are fine for you i will get solution in next comment. |
Ok so you are saying that it doesn't work for any algorithm, right? If so, could you try this and post the result here: $privkey = openssl_pkey_new(array(
"digest_alg"=>'sha256',
"private_key_bits" => 2048,
"private_key_type" => OPENSSL_KEYTYPE_RSA,
));
var_dump($privkey);
while ($error = openssl_error_string()) var_dump($error);
var_dump(openssl_pkey_get_details($privkey)); |
It cannot find you openssl.cnf so you might need to do one of following:
It actually should not really need it as all needed args are defined but it might be failing because of that. I would first try to address this and see. PHP-8.1 might have different configuration potentially. |
Have you tried your PC or laptop? Please provide a screenshot of the PHP 8.3 version where it is working |
Those are not random answers but it is based on what your errors say. I'm just trying to help you to figure it out but essentially it's up to you to fix it because this is not a PHP issue but more your setup issue (we have got Windows tests that normally work and usual sdk setup works fine as well). WampServer is not a PHP project so it is their setup. You might need to ask on stack overflow or WampServer forum for help. The only thing that we can potential do is to make things easier for Windows users so I will see if I find time to try it and see if there is anything unusual in WampServer seupt but currently busy with other things so it might take some time. |
Also if they use OpenSSL 3.2, then they most likely use unofficial build which is not provided by PHP project. |
It's okay brother if you require time my concern was if it is not working then in the next build please update and release. I am 90% sure something is missing in the library it is not about Wamp they don't build PHP they provide the environment thanks for your help and time. |
But we don't have builds for OpenSSL 3.2 currently (PHP 8.1 is build with OpenSSL 1.1.1 and PHP 8.2 and 8.3 is build with OpenSSL 3.0). Are you sure that your are using that (you can check it by running |
@Pratik2121 you have a missing With the code @bukka posted, I get this:
|
Yeah it looks to me like most likely missing |
I'm going to close this. If you see any issue on PHP side (if it's still not working after openssl.cnf is present), please comment here with all the details. |
Uh oh!
There was an error while loading. Please reload this page.
Description
The following code is not working after the 8.2 version
PHP Version
PHP 8.3
Operating System
Windows 10
The text was updated successfully, but these errors were encountered: