Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,15 @@ PHP_FUNCTION(openssl_pkcs12_read)
zval * zextracert;
X509* aCA = sk_X509_pop(ca);
if (!aCA) break;


/* fix for bug 69882 */
{
int err = ERR_peek_error();
if (err == OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH) {
ERR_get_error();
}
}

bio_out = BIO_new(BIO_s_mem());
if (PEM_write_bio_X509(bio_out, aCA)) {
BUF_MEM *bio_buf;
Expand Down
2 changes: 2 additions & 0 deletions ext/openssl/php_openssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ extern zend_module_entry openssl_module_entry;
#define OPENSSL_RAW_DATA 1
#define OPENSSL_ZERO_PADDING 2

#define OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH 0x0B080074

/* Used for client-initiated handshake renegotiation DoS protection*/
#define OPENSSL_DEFAULT_RENEG_LIMIT 2
#define OPENSSL_DEFAULT_RENEG_WINDOW 300
Expand Down
17 changes: 17 additions & 0 deletions ext/openssl/tests/bug69882.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Bug #69882: OpenSSL error "key values mismatch" after openssl_pkcs12_read with extra certs
--SKIPIF--
<?php
if (!extension_loaded("openssl")) die("skip");
?>
--FILE--
<?php
$p12 = file_get_contents(__DIR__.'/p12_with_extra_certs.p12');

$result = openssl_pkcs12_read($p12, $cert_data, 'qwerty');
var_dump($result);
var_dump(openssl_error_string());
?>
--EXPECTF--
bool(true)
bool(false)
Binary file added ext/openssl/tests/p12_with_extra_certs.p12
Binary file not shown.