1--TEST--
2openssl_csr_new() attributes setting tests
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7
8$dn = array(
9    "countryName" => "UK",
10    "stateOrProvinceName" => "England",
11    "localityName" => "London",
12    "commonName" => "test.php.net",
13    "emailAddress" => "test.php@php.net"
14);
15
16
17$config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl_csr_attribs.cnf';
18
19$config_arg = array('config' => $config);
20
21$args = array(
22    "digest_alg" => "sha256",
23    "private_key_bits" => 2048,
24    "private_key_type" => OPENSSL_KEYTYPE_DSA,
25    "encrypt_key" => true,
26    "config" => $config,
27);
28
29$privkey = 'file://' . __DIR__ . '/private_rsa_2048.key';
30
31$csr = openssl_csr_new(
32    $dn,
33    $privkey,
34    $args,
35    [
36        'emailAddress' => 'info@example.com',
37        'aansluitNummer' => '11112222',
38        'postalCode' => 'N11',
39    ]
40);
41
42
43var_dump(openssl_csr_get_subject($csr));
44var_dump(openssl_csr_export($csr, $output));
45var_dump($output);
46
47var_dump(openssl_csr_new(
48    $dn,
49    $privkey,
50    $args,
51    ['wrong' => 'info@example.com']
52));
53
54?>
55--EXPECTF--
56array(5) {
57  ["C"]=>
58  string(2) "UK"
59  ["ST"]=>
60  string(7) "England"
61  ["L"]=>
62  string(6) "London"
63  ["CN"]=>
64  string(12) "test.php.net"
65  ["emailAddress"]=>
66  string(16) "test.php@php.net"
67}
68bool(true)
69string(1269) "-----BEGIN CERTIFICATE REQUEST-----
70MIIDcDCCAlgCAQAwaDELMAkGA1UEBhMCVUsxEDAOBgNVBAgMB0VuZ2xhbmQxDzAN
71BgNVBAcMBkxvbmRvbjEVMBMGA1UEAwwMdGVzdC5waHAubmV0MR8wHQYJKoZIhvcN
72AQkBFhB0ZXN0LnBocEBwaHAubmV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
73CgKCAQEArbUmVW1Y+rJzZRC3DYB0kdIgvk7MAday78ybGPPDhVlbAb4CjWbaPs4n
74yUCTEt9KVG0H7pXHxDbWSsC2974zdvqlP0L2op1/M2SteTcGCBOdwGH2jORVAZL8
75/WbTOf9IpKAM77oN14scsyOlQBJqhh+xrLg8ksB2dOos54yDqo0Tq7R5tldV+alK
76ZXWlJnqRCfFuxvqtfWI5nGTAedVZhvjQfLQQgujfXHoFWoGbXn2buzfwKGJEeqWP
77bQOZF/FeOJPlgOBhhDb3BAFNVCtM3k71Rblj54pNd3yvq152xsgFd0o3s15fuSwZ
78gerUjeEuw/wTK9k7vyp+MrIQHQmPdQIDAQABoIHCMAkGA1UECTECDAAwCQYDVQQX
79MQIMADAMBgNVBBExBQwDTjExMBIGA1UEFDELDAkwMTIzNDU2NzgwFQYDVQQpMQ4M
80DE9yZ2FuaXNhdGlvbjAZBgsrBgEEAdgOiH4CATEKDAgxMTExMjIyMjAZBgsrBgEE
81AdgOiH4CAjEKDAgxMjM0NTY3ODAaBgkqhkiG9w0BCQ4xDTALMAkGA1UdEwQCMAAw
82HwYJKoZIhvcNAQkBMRIWEGluZm9AZXhhbXBsZS5jb20wDQYJKoZIhvcNAQELBQAD
83ggEBAAoPI/sWY0QKPMEBuRp6MHcvWgSExwkkQfRJQZlYdepu6Tw0iZwYRTOR4sEn
84Vz95qsrWqHp6QkXxdFG9FPHi4N66OX2Xb5TtHgDGMxrJTwbH+7VdsJiXLkWbeLuo
85zKv8BsrhLRYiZkl+VWIrNyOcK7ao2sD+D3YkCBA4JK4OFhfhxY43D2sme7aEQVjr
86S+UvEjuIALN0AP6gO2AMiUODPBrjsPI3NpN40VUvVU+Hsp1Tlqvth/AYASuGT2yt
87M5YdcSm7JwaGAwIgOv8XPUQGem52yMEvzySRC4ZyTddfiZAkeTLmbh+SMVbHXXOk
88UeEz+fvmQ4L+sc3RE8u+M8g31LM=
89-----END CERTIFICATE REQUEST-----
90"
91
92Warning: openssl_csr_new(): attributes: wrong is not a recognized attribute name in %s on line %d
93object(OpenSSLCertificateSigningRequest)#%d (0) {
94}