xref: /PHP-7.4/ext/openssl/tests/bug36732.phpt (revision 782352c5)
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");
6?>
7--FILE--
8<?php
9$configargs = array(
10    "req_extensions" => "v3_req",
11    "x509_extensions" => "usr_cert",
12    "config" => __DIR__. DIRECTORY_SEPARATOR . "openssl.cnf",
13);
14
15$dn = array(
16    "countryName" => "GB",
17    "stateOrProvinceName" => "Berkshire",
18    "localityName" => "Newbury",
19    "organizationName" => "My Company Ltd",
20    "commonName" => "Demo Cert"
21);
22
23$key = openssl_pkey_new();
24$csr = openssl_csr_new($dn, $key, $configargs);
25$crt = openssl_csr_sign($csr, NULL, $key, 365, $configargs);
26
27$str = '';
28openssl_csr_export($csr, $str, false);
29
30if (strpos($str, 'Requested Extensions:')) {
31    echo "Ok\n";
32}
33openssl_x509_export($crt, $str, false);
34if (strpos($str, 'X509v3 extensions:')) {
35    echo "Ok\n";
36}
37?>
38--EXPECT--
39Ok
40Ok
41