Req #67403 [NEW]: Add signatureType to openssl_x509_parse
From: mark at zedwood dot com
Operating system: Ubuntu 14.04
PHP version: 5.5.13
Package: OpenSSL related
Bug Type: Feature/Change Request
Bug description:Add signatureType to openssl_x509_parse
Description:
------------
One of the main attributes of an x509 certificate that is not parsed or
exposed in openssl_x509_parse, is the signature type. On a linux
command line, running "cat my.pem|openssl x509 -noout -text" does
provide the signature type, but there should be a native way in php to
parse this out of a certificate without having to fallback to the
command line.
Reading the source code, it looks like someone else tried to add it, but
left it commented out, see: ext/openssl/openssl.c around line 1540...
/*
add_assoc_long(return_value, "signaturetypeLONG",
X509_get_signature_type(cert));
add_assoc_string(return_value, "signaturetype",
OBJ_nid2sn(X509_get_signature_type(cert)), 1);
add_assoc_string(return_value, "signaturetypeLN",
OBJ_nid2ln(X509_get_signature_type(cert)), 1);
*/
It was commented out, because the code did not work. Perhaps there is a
way to provide this functionality.
Test script:
---------------
<?php
$cert=<<<EOF
-----BEGIN CERTIFICATE-----
MIIBBzCBrgIJANZXs2GIGRy3MAoGCCqGSM49BAMDMAwxCjAIBgNVBAMMAXgwHhcN
MTQwNjA5MTczMjQ1WhcNMjQwNjA2MTczMjQ1WjAMMQowCAYDVQQDDAF4MFkwEwYH
KoZIzj0CAQYIKoZIzj0DAQcDQgAEK8KP9tJ1bZxLGKqNP9JpOkaq9paKoMS4/0wm
6u62b0mArY7xmS5/Nlkyi/GK21QpjSk4vRwkN+tYPeAy/8Bd2TAKBggqhkjOPQQD
AwNIADBFAiAjVRQZKlKCBzJxJ7aw8qRrZUhBczX9psneshOhI7g4mQIhAPlTbP67
mq9Qf/YphH6gWZXX50TGC2OTOUXRm60Cajs3
-----END CERTIFICATE-----
EOF;
$r = openssl_x509_parse($cert);
echo $r['signatureType']."\n";
Expected result:
----------------
string(23) "sha256WithRSAEncryption"
Actual result:
--------------
NULL
--
Edit bug report at https://bugs.php.net/bug.php?id=67403&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67403&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67403&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67403&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67403&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67403&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67403&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67403&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67403&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67403&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67403&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67403&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67403&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67403&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67403&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67403&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67403&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67403&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67403&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67403&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67403&r=mysqlcfg
Thread (6 messages)
- mark at zedwood dot com