File: openssl_csr_new_array_dn_entry.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (59 lines) | stat: -rw-r--r-- 1,207 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--TEST--
openssl_csr_new() with array DN entry
--EXTENSIONS--
openssl
--FILE--
<?php

$a = array();

$conf = array('config' => __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf');

// options type check
$x = openssl_pkey_new($conf);
$csr = openssl_csr_new(
    [    
        "countryName" => "GB",
        "stateOrProvinceName" => "Somerset",
        "localityName" => "Glastonbury",
        "organizationName" => ["o1" => "PHP", "o2" => "PHP Foundation"],
        "organizationalUnitName" => ["PHP Doc team", "PHP Admin team", "PHP Core team"],
        "commonName" => "test.php.net",
        "emailAddress" => "php.test@example.com"
    ],
    $x,
    $conf + ["x509_extensions" => 0xDEADBEEF]
);

var_dump(openssl_csr_get_subject($csr));

?>
--EXPECT--
array(7) {
  ["C"]=>
  string(2) "GB"
  ["ST"]=>
  string(8) "Somerset"
  ["L"]=>
  string(11) "Glastonbury"
  ["O"]=>
  array(2) {
    [0]=>
    string(3) "PHP"
    [1]=>
    string(14) "PHP Foundation"
  }
  ["OU"]=>
  array(3) {
    [0]=>
    string(12) "PHP Doc team"
    [1]=>
    string(14) "PHP Admin team"
    [2]=>
    string(13) "PHP Core team"
  }
  ["CN"]=>
  string(12) "test.php.net"
  ["emailAddress"]=>
  string(20) "php.test@example.com"
}