summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2002-03-28 00:56:19 +0000
committerWez Furlong <wez@php.net>2002-03-28 00:56:19 +0000
commit959021a8c97e47cfcbbf4fa9ca8a79e9f5e57074 (patch)
tree9d7f887d4769ec421c5fcb5508b07df9ff5441cf /ext/openssl
parent2539cbc74c4f2cca2f39f99b2d679bb4e329b53d (diff)
downloadphp-git-959021a8c97e47cfcbbf4fa9ca8a79e9f5e57074.tar.gz
Add subject hash to parsed x509 data.
Make the test use file_get_contents().
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/openssl.c7
-rw-r--r--ext/openssl/tests/001.phpt6
2 files changed, 10 insertions, 3 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index e3d92a4ec9..425c1359d1 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -819,6 +819,13 @@ PHP_FUNCTION(openssl_x509_parse)
/* add_assoc_bool(return_value, "valid", cert->valid); */
add_assoc_name_entry(return_value, "subject", X509_get_subject_name(cert), useshortnames);
+ /* hash as used in CA directories to lookup cert by subject name */
+ {
+ char buf[32];
+ snprintf(buf, sizeof(buf), "%08lx", X509_subject_name_hash(cert));
+ add_assoc_string(return_value, "hash", buf, 1);
+ }
+
add_assoc_name_entry(return_value, "issuer", X509_get_issuer_name(cert), useshortnames);
add_assoc_long(return_value, "version", X509_get_version(cert));
add_assoc_long(return_value, "serialNumber", ASN1_INTEGER_get(X509_get_serialNumber(cert)));
diff --git a/ext/openssl/tests/001.phpt b/ext/openssl/tests/001.phpt
index 06a9c04bf5..2c2f9008b1 100644
--- a/ext/openssl/tests/001.phpt
+++ b/ext/openssl/tests/001.phpt
@@ -42,9 +42,7 @@ openssl_pkey_free($loaded_key);
echo "Load key manually and use string syntax\n";
-$fp = fopen($key_file_name, "r");
-$key_content = fread($fp, filesize($key_file_name));
-fclose($fp);
+$key_content = file_get_contents($key_file_name);
$loaded_key = openssl_pkey_get_private($key_content, $passphrase);
if ($loaded_key === false)
@@ -54,6 +52,8 @@ openssl_pkey_free($loaded_key);
echo "OK!\n";
+@unlink($key_file_name);
+
?>
--EXPECT--
Creating private key