xref: /PHP-7.0/ext/openssl/tests/bug36732.phpt (revision 7b392c71)
1--TEST--
2Bug #36732 (add support for req_extensions in openss_csr_new and sign)
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip");
6if (OPENSSL_VERSION_NUMBER < 0x009070af) die("skip");
7?>
8--FILE--
9<?php
10$configargs = array(
11        "req_extensions" => "v3_req",
12        "x509_extensions" => "usr_cert",
13		"config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
14);
15
16$dn = array(
17        "countryName" => "GB",
18        "stateOrProvinceName" => "Berkshire",
19        "localityName" => "Newbury",
20        "organizationName" => "My Company Ltd",
21        "commonName" => "Demo Cert"
22);
23
24$key = openssl_pkey_new();
25$csr = openssl_csr_new($dn, $key, $configargs);
26$crt = openssl_csr_sign($csr, NULL, $key, 365, $configargs);
27
28$str = '';
29openssl_csr_export($csr, $str, false);
30
31if (strpos($str, 'Requested Extensions:')) {
32	echo "Ok\n";
33}
34openssl_x509_export($crt, $str, false);
35if (strpos($str, 'X509v3 extensions:')) {
36	echo "Ok\n";
37}
38?>
39--EXPECTF--
40Ok
41Ok
42