|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-01-31 13:13 UTC] ckmailid at gmail dot com
Description:
------------
PHP process crashes when i use a pfx file to read using function openssl_pkcs12_read with valid password.
But it gives error if password is wrong, that is working fine.
That pfx file is working well with openssl command line utility
Environment :
PHP : 7 .0.9
OS: windows 10
Server: IIS, Using Fast CGI
certificate : It is specially exported certificate from windows. when a highly secure certificate is exported , it asks for login user password, and after 4 attempt with wrong password it export the certificate even after wrong password.
You can do it by import a pfx file that with enabling strong private key encrypting checkbox on wizard and after finish set security level HIGH.
I tried it on linux with gdb, it shows Segmentation fault (core dumped).
Test script:
---------------
if (!$cert_store = file_get_contents("sample_export.pfx")) {
echo "Error: Unable to read the cert file\n";
exit;
}
if (openssl_pkcs12_read($cert_store, $cert_info, "csos")) {
echo "Certificate Information\n";
print_r($cert_info);
} else {
echo "Error: Unable to read the cert store.\n";
exit;
}
Expected result:
----------------
it will crash the PHP process.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 10:00:01 2025 UTC |
I've confirmed this suspicion. Following patch (against 7.1.5) fixes the problem: @@ -2972,11 +2972,9 @@ PHP_FUNCTION(openssl_pkcs12_read) } if (ca && sk_X509_num(ca)) { - int num; array_init(&zextracerts); - num = sk_X509_num(ca); - for (i = 0; i < num; i++) { + for (i = 0; i < sk_X509_num(ca); i++) { zval zextracert; X509* aCA = sk_X509_pop(ca); if (!aCA) break;