From: laurent dot jouannic at cbsa dot fr
Operating system: debian
PHP version: 5.2.9
PHP Bug Type: OpenSSL related
Bug description: openssl_csr_sign doesn't change serial value
Description:
------------
When I manualy sign a certificate from the shell:
./CA.sh -sign
or
openssl ca -policy policy_anything -out newcert.pem -infiles newreq.pem
the value in the file 'serial' increase ($value++).
When I sign a certificate with php (openssl_csr_sign):
-the serial (file) doesn't change
-the new certificate has a good 'serial' value
Reproduce code:
---------------
$CAcrt = file_get_contents("/usr/lib/ssl/misc/demoCA/cacert.pem");
$serial_hexa = file_get_contents("/usr/lib/ssl/misc/demoCA/serial");
$serial_dec_net=intval($serial_hexa,16); /*04*/
$CAkey =
array(file_get_contents("/usr/lib/ssl/misc/demoCA/private/cakey.pem"),
"Gas/ZWmUkz7y2");
echo "--".$serial_hexa."--";
echo "<br>++".$serian_dec_net."++";
$clientKeys = openssl_pkey_new();
$dn = array(
"countryName" => "FR",
"stateOrProvinceName" => "Ain",
"localityName" => "Jouan",
"organizationName" => "Certificat client",
"organizationalUnitName" => "Info",
"commonName" => "www.abc.fr",
"emailAddress" => "[email protected]"
);
$csr = openssl_csr_new($dn, $clientPrivKey);
$config = array(
"config" => "/etc/ssl/openssl.cnf",
);
$cert = openssl_csr_sign($csr, $CAcrt, $CAkey, 1095, $config, '04');
openssl_x509_export($cert, $certout);
echo $certout;
openssl_pkcs12_export_to_file ( $certout, "tmp/tito.p12" ,
$clientPrivKey , "mimine")
Expected result:
----------------
The result is good, as the certificate, but the value inside 'serial'
doesn't change....
--
Edit bug report at http://bugs.php.net/?id=47863&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47863&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47863&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47863&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47863&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47863&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47863&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47863&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47863&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47863&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47863&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47863&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47863&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47863&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47863&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47863&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47863&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47863&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47863&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47863&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47863&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47863&r=mysqlcfg