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