1--TEST--
2openssl_x509_parse() tests
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7$cert = "file://" . __DIR__ . "/cert.crt";
8
9$parsedCert = openssl_x509_parse($cert);
10var_dump($parsedCert === openssl_x509_parse(openssl_x509_read($cert)));
11var_dump($parsedCert);
12var_dump(openssl_x509_parse($cert, false));
13?>
14--EXPECTF--
15bool(true)
16array(16) {
17  ["name"]=>
18  string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net"
19  ["subject"]=>
20  array(5) {
21    ["C"]=>
22    string(2) "BR"
23    ["ST"]=>
24    string(17) "Rio Grande do Sul"
25    ["L"]=>
26    string(12) "Porto Alegre"
27    ["CN"]=>
28    string(21) "Henrique do N. Angelo"
29    ["emailAddress"]=>
30    string(16) "hnangelo@php.net"
31  }
32  ["hash"]=>
33  string(8) "%s"
34  ["issuer"]=>
35  array(5) {
36    ["C"]=>
37    string(2) "BR"
38    ["ST"]=>
39    string(17) "Rio Grande do Sul"
40    ["L"]=>
41    string(12) "Porto Alegre"
42    ["CN"]=>
43    string(21) "Henrique do N. Angelo"
44    ["emailAddress"]=>
45    string(16) "hnangelo@php.net"
46  }
47  ["version"]=>
48  int(2)
49  ["serialNumber"]=>
50  string(20) "12593567369101004962"
51  ["serialNumberHex"]=>
52  string(16) "AEC556CC723750A2"
53  ["validFrom"]=>
54  string(13) "080630102843Z"
55  ["validTo"]=>
56  string(13) "080730102843Z"
57  ["validFrom_time_t"]=>
58  int(1214821723)
59  ["validTo_time_t"]=>
60  int(1217413723)
61  ["signatureTypeSN"]=>
62  string(8) "RSA-SHA1"
63  ["signatureTypeLN"]=>
64  string(21) "sha1WithRSAEncryption"
65  ["signatureTypeNID"]=>
66  int(65)
67  ["purposes"]=>
68  array(9) {
69    [1]=>
70    array(3) {
71      [0]=>
72      bool(true)
73      [1]=>
74      bool(true)
75      [2]=>
76      string(9) "sslclient"
77    }
78    [2]=>
79    array(3) {
80      [0]=>
81      bool(true)
82      [1]=>
83      bool(true)
84      [2]=>
85      string(9) "sslserver"
86    }
87    [3]=>
88    array(3) {
89      [0]=>
90      bool(true)
91      [1]=>
92      bool(true)
93      [2]=>
94      string(11) "nssslserver"
95    }
96    [4]=>
97    array(3) {
98      [0]=>
99      bool(true)
100      [1]=>
101      bool(true)
102      [2]=>
103      string(9) "smimesign"
104    }
105    [5]=>
106    array(3) {
107      [0]=>
108      bool(true)
109      [1]=>
110      bool(true)
111      [2]=>
112      string(12) "smimeencrypt"
113    }
114    [6]=>
115    array(3) {
116      [0]=>
117      bool(true)
118      [1]=>
119      bool(true)
120      [2]=>
121      string(7) "crlsign"
122    }
123    [7]=>
124    array(3) {
125      [0]=>
126      bool(true)
127      [1]=>
128      bool(true)
129      [2]=>
130      string(3) "any"
131    }
132    [8]=>
133    array(3) {
134      [0]=>
135      bool(true)
136      [1]=>
137      bool(true)
138      [2]=>
139      string(10) "ocsphelper"
140    }
141    [9]=>
142    array(3) {
143      [0]=>
144      bool(false)
145      [1]=>
146      bool(true)
147      [2]=>
148      string(13) "timestampsign"
149    }
150  }
151  ["extensions"]=>
152  array(3) {
153    ["subjectKeyIdentifier"]=>
154    string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D"
155    ["authorityKeyIdentifier"]=>
156    string(%d) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
157DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net
158serial:AE:C5:56:CC:72:37:50:A2%A"
159    ["basicConstraints"]=>
160    string(7) "CA:TRUE"
161  }
162}
163array(16) {
164  ["name"]=>
165  string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net"
166  ["subject"]=>
167  array(5) {
168    ["countryName"]=>
169    string(2) "BR"
170    ["stateOrProvinceName"]=>
171    string(17) "Rio Grande do Sul"
172    ["localityName"]=>
173    string(12) "Porto Alegre"
174    ["commonName"]=>
175    string(21) "Henrique do N. Angelo"
176    ["emailAddress"]=>
177    string(16) "hnangelo@php.net"
178  }
179  ["hash"]=>
180  string(8) "%s"
181  ["issuer"]=>
182  array(5) {
183    ["countryName"]=>
184    string(2) "BR"
185    ["stateOrProvinceName"]=>
186    string(17) "Rio Grande do Sul"
187    ["localityName"]=>
188    string(12) "Porto Alegre"
189    ["commonName"]=>
190    string(21) "Henrique do N. Angelo"
191    ["emailAddress"]=>
192    string(16) "hnangelo@php.net"
193  }
194  ["version"]=>
195  int(2)
196  ["serialNumber"]=>
197  string(20) "12593567369101004962"
198  ["serialNumberHex"]=>
199  string(16) "AEC556CC723750A2"
200  ["validFrom"]=>
201  string(13) "080630102843Z"
202  ["validTo"]=>
203  string(13) "080730102843Z"
204  ["validFrom_time_t"]=>
205  int(1214821723)
206  ["validTo_time_t"]=>
207  int(1217413723)
208  ["signatureTypeSN"]=>
209  string(8) "RSA-SHA1"
210  ["signatureTypeLN"]=>
211  string(21) "sha1WithRSAEncryption"
212  ["signatureTypeNID"]=>
213  int(65)
214  ["purposes"]=>
215  array(9) {
216    [1]=>
217    array(3) {
218      [0]=>
219      bool(true)
220      [1]=>
221      bool(true)
222      [2]=>
223      string(10) "SSL client"
224    }
225    [2]=>
226    array(3) {
227      [0]=>
228      bool(true)
229      [1]=>
230      bool(true)
231      [2]=>
232      string(10) "SSL server"
233    }
234    [3]=>
235    array(3) {
236      [0]=>
237      bool(true)
238      [1]=>
239      bool(true)
240      [2]=>
241      string(19) "Netscape SSL server"
242    }
243    [4]=>
244    array(3) {
245      [0]=>
246      bool(true)
247      [1]=>
248      bool(true)
249      [2]=>
250      string(14) "S/MIME signing"
251    }
252    [5]=>
253    array(3) {
254      [0]=>
255      bool(true)
256      [1]=>
257      bool(true)
258      [2]=>
259      string(17) "S/MIME encryption"
260    }
261    [6]=>
262    array(3) {
263      [0]=>
264      bool(true)
265      [1]=>
266      bool(true)
267      [2]=>
268      string(11) "CRL signing"
269    }
270    [7]=>
271    array(3) {
272      [0]=>
273      bool(true)
274      [1]=>
275      bool(true)
276      [2]=>
277      string(11) "Any Purpose"
278    }
279    [8]=>
280    array(3) {
281      [0]=>
282      bool(true)
283      [1]=>
284      bool(true)
285      [2]=>
286      string(11) "OCSP helper"
287    }
288    [9]=>
289    array(3) {
290      [0]=>
291      bool(false)
292      [1]=>
293      bool(true)
294      [2]=>
295      string(18) "Time Stamp signing"
296    }
297  }
298  ["extensions"]=>
299  array(3) {
300    ["subjectKeyIdentifier"]=>
301    string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D"
302    ["authorityKeyIdentifier"]=>
303    string(%d) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
304DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net
305serial:AE:C5:56:CC:72:37:50:A2%A"
306    ["basicConstraints"]=>
307    string(7) "CA:TRUE"
308  }
309}
310