What issue or error are you experiencing?
By default the OpenSSL configuration is not referenced correctly anymore. The following call used to give a valid result for a fresh Local site:
$key_resource = openssl_pkey_new([
"digest_alg" => 'sha512',
"private_key_bits" => 4096,
"private_key_type" => OPENSSL_KEYTYPE_RSA
]);
$public_key = openssl_pkey_get_details($key_resource)['key'];
but now only works when explicitly giving a “config” argument pointing to a openssl.cnf.
What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc
- Create new Local site (PHP Version does not seem to matter).
- Add a plugin that does the call:
$key_resource = openssl_pkey_new([ "digest_alg" => 'sha512', "private_key_bits" => 4096, "private_key_type" => OPENSSL_KEYTYPE_RSA ]); $public_key = openssl_pkey_get_details($key_resource)['key'];
- See that
$key_resource
isfalse
and thusopenssl_pkey_get_details($key_resource)['key'];
returns an error:Uncaught TypeError: openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given
The issue can be fixed using the following steps:
- Copy the
openssl.cnf
from~\AppData\Roaming\Local\lightning-services\php-8.0.22+6\bin\win64\extras\ssl
to a different location (e.g.c:\temp\openssl.cnf
) - Edit the call to account for the new location
$key_resource = openssl_pkey_new([ "config"=> "c:\\temp\\openssl.cnf", "digest_alg" => 'sha512', "private_key_bits" => 4096, "private_key_type" => OPENSSL_KEYTYPE_RSA ]);
- Verify that
$key_resource
is no longer false (although it will not be able to create a private key with the using theopenssl_pkey_export
, but I take it that that’s a problem with the configuration in itself).
System Details
-
Local Version: 7.1.2
-
Operating System (OS) and OS version: Windows 10 (10.0.19045 Build 19045)
Local Logs
Uncaught TypeError: openssl_pkey_get_details(): Argument #1 ($key) must be of type OpenSSLAsymmetricKey, bool given