mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-28 03:06:24 +08:00
Add PHP Extension for GmSSL
View http://gmssl.org/docs/php-api.html for more info.
This commit is contained in:
41
php/ext/openssl/tests/bug36732.phpt
Normal file
41
php/ext/openssl/tests/bug36732.phpt
Normal file
@@ -0,0 +1,41 @@
|
||||
--TEST--
|
||||
Bug #36732 (add support for req_extensions in openss_csr_new and sign)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("openssl")) die("skip");
|
||||
if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$configargs = array(
|
||||
"req_extensions" => "v3_req",
|
||||
"x509_extensions" => "usr_cert",
|
||||
"config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
|
||||
);
|
||||
|
||||
$dn = array(
|
||||
"countryName" => "GB",
|
||||
"stateOrProvinceName" => "Berkshire",
|
||||
"localityName" => "Newbury",
|
||||
"organizationName" => "My Company Ltd",
|
||||
"commonName" => "Demo Cert"
|
||||
);
|
||||
|
||||
$key = openssl_pkey_new();
|
||||
$csr = openssl_csr_new($dn, $key, $configargs);
|
||||
$crt = openssl_csr_sign($csr, NULL, $key, 365, $configargs);
|
||||
|
||||
$str = '';
|
||||
openssl_csr_export($csr, $str, false);
|
||||
|
||||
if (strpos($str, 'Requested Extensions:')) {
|
||||
echo "Ok\n";
|
||||
}
|
||||
openssl_x509_export($crt, $str, false);
|
||||
if (strpos($str, 'X509v3 extensions:')) {
|
||||
echo "Ok\n";
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Ok
|
||||
Ok
|
||||
Reference in New Issue
Block a user