Skip to content

Commit 03a670e

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: Fixed #69882: OpenSSL error "key values mismatch" after openssl_pkcs12_read with extra certs
2 parents 7ceb474 + 2ff3daf commit 03a670e

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
. Fixed Bug #53823 (preg_replace: * qualifier on unicode replace garbles the
1010
string). (cmb)
1111

12+
- OpenSSL:
13+
. Fixed bug #69882 (OpenSSL error “key values mismatch” after
14+
openssl_pkcs12_read with extra cert) (Tomasz Sawicki)
15+
1216
25 Jun 2015, PHP 7.0.0 Alpha 2
1317

1418
- Core:

ext/openssl/openssl.c

+8
Original file line numberDiff line numberDiff line change
@@ -2575,6 +2575,14 @@ PHP_FUNCTION(openssl_pkcs12_read)
25752575
X509* aCA = sk_X509_pop(ca);
25762576
if (!aCA) break;
25772577

2578+
/* fix for bug 69882 */
2579+
{
2580+
int err = ERR_peek_error();
2581+
if (err == OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH) {
2582+
ERR_get_error();
2583+
}
2584+
}
2585+
25782586
bio_out = BIO_new(BIO_s_mem());
25792587
if (PEM_write_bio_X509(bio_out, aCA)) {
25802588
BUF_MEM *bio_buf;

ext/openssl/php_openssl.h

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ extern zend_module_entry openssl_module_entry;
3232
#define OPENSSL_RAW_DATA 1
3333
#define OPENSSL_ZERO_PADDING 2
3434

35+
#define OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH 0x0B080074
36+
3537
/* Used for client-initiated handshake renegotiation DoS protection*/
3638
#define OPENSSL_DEFAULT_RENEG_LIMIT 2
3739
#define OPENSSL_DEFAULT_RENEG_WINDOW 300

ext/openssl/tests/bug69882.phpt

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #69882: OpenSSL error "key values mismatch" after openssl_pkcs12_read with extra certs
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("openssl")) die("skip");
6+
?>
7+
--FILE--
8+
<?php
9+
$p12 = file_get_contents(__DIR__.'/p12_with_extra_certs.p12');
10+
11+
$result = openssl_pkcs12_read($p12, $cert_data, 'qwerty');
12+
var_dump($result);
13+
var_dump(openssl_error_string());
14+
?>
15+
--EXPECTF--
16+
bool(true)
17+
bool(false)
3.13 KB
Binary file not shown.

0 commit comments

Comments
 (0)