[php-src] Issue #12128: Unable to read the cert store when Using openssl_pkcs12_read with OpenSSL 3.x
| From: | JohnyRooke | Date: | Tue, 05 Sep 2023 10:20:30 +0000 |
| Subject: | [php-src] Issue #12128: Unable to read the cert store when Using openssl_pkcs12_read with OpenSSL 3.x | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245334@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12128
Author: JohnyRooke
### Description
The following code:
```php
<?php
if (!$cert_store = file_get_contents("/certs/file.p12")) {
echo "Error: Unable to read the cert file.";
exit;
}
if (openssl_pkcs12_read($cert_store, $cert_info, "my_secret_pass")) {
echo "Certificate Information:";
print_r($cert_info);
} else {
echo "Error: Unable to read the cert store.";
exit;
}
?>
```
Resulted in this output:
```
Error: Unable to read the cert store.
```
But I expected this output instead:
```
Certificate Information:
Array
(
[cert] => -----BEGIN CERTIFICATE-----
ICAL0wDQYJKoZIhvcNAQELBQAwgYkxCzAJBgNVBAYTAk
-----END CERTIFICATE-----,
[pkey] => -----BEGIN PRIVATE KEY-----
LyaH3FnQfJkGmc0CgGAV72ecpf06CRrUYVl5sBUcKcT67O
-----END PRIVATE KEY-----
)
// The values are only examples.
```
The error does not occur in earlier versions, such as PHP 8.2.6 and 8.2.7, which utilize OpenSSL
version 1.x. Starting from PHP version 8.2.8 onwards, OpenSSL 3.x is employed, and the error occurs
as previously mentioned.
### PHP Version
PHP 8.2.8
### Operating System
Ubuntu 20.04