Bug #66122 [NEW]: Certification cannot be used directly after openssl_csr_sign
From: phpbugs at lavoie dot sl
Operating system: Linux/Mac
PHP version: 5.5.6
Package: OpenSSL related
Bug Type: Bug
Bug description:Certification cannot be used directly after openssl_csr_sign
Description:
------------
When generating a CRT using KEY/CSR, the certificate resource is not
"ready". To use it, you have to export and import it back.
The test was done using a CA or a selfsigned.
Tested on 3 systems:
OSX 10.9
PHP 5.5.6 (brew)
OpenSSL 1.0.1e
Ubuntu
PHP 5.4.21-1+debphp.org~quantal+1
OpenSSL 1.0.1c
PHP 5.3.10-1ubuntu3.6
OpenSSL 1.0.1 (Native)
If nobody can reproduce this, I can post the rest of the system
configurations
Test script:
---------------
<?php
$key = openssl_pkey_new();
$csr = openssl_csr_new(array(), $key);
$crt = openssl_csr_sign($csr, null, $key, 365 * 100);
openssl_pkcs7_encrypt($plain1, $enc, $crt, array('foo' => 'bar'));
openssl_pkcs7_decrypt($enc, $plain2, $crt, $key); // error, empty
?>
Full example:
https://gist.github.com/lavoiesl/7557763/raw/openssl-test.php
Expected result:
----------------
string(0) "hello"
string(5) "hello"
string(0) "hello"
array(0) {
}
Actual result:
--------------
error:21070073:PKCS7 routines:PKCS7_dataDecode:no recipient matches
certificatestring(0) ""
string(5) "hello"
error:21070073:PKCS7 routines:PKCS7_dataDecode:no recipient matches
certificatestring(0) ""
array(0) {
}
--
Edit bug report at https://bugs.php.net/bug.php?id=66122&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66122&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66122&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66122&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=66122&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=66122&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=66122&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=66122&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=66122&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=66122&r=support
Expected behavior: https://bugs.php.net/fix.php?id=66122&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=66122&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=66122&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=66122&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66122&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=66122&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=66122&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=66122&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=66122&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=66122&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=66122&r=mysqlcfg
Thread (2 messages)
- phpbugs at lavoie dot sl