1--TEST--
2openssl_x509_parse() tests
3--SKIPIF--
4<?php if (!extension_loaded("openssl")) print "skip"; ?>
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(202) "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
159"
160    ["basicConstraints"]=>
161    string(7) "CA:TRUE"
162  }
163}
164array(16) {
165  ["name"]=>
166  string(96) "/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net"
167  ["subject"]=>
168  array(5) {
169    ["countryName"]=>
170    string(2) "BR"
171    ["stateOrProvinceName"]=>
172    string(17) "Rio Grande do Sul"
173    ["localityName"]=>
174    string(12) "Porto Alegre"
175    ["commonName"]=>
176    string(21) "Henrique do N. Angelo"
177    ["emailAddress"]=>
178    string(16) "hnangelo@php.net"
179  }
180  ["hash"]=>
181  string(8) "%s"
182  ["issuer"]=>
183  array(5) {
184    ["countryName"]=>
185    string(2) "BR"
186    ["stateOrProvinceName"]=>
187    string(17) "Rio Grande do Sul"
188    ["localityName"]=>
189    string(12) "Porto Alegre"
190    ["commonName"]=>
191    string(21) "Henrique do N. Angelo"
192    ["emailAddress"]=>
193    string(16) "hnangelo@php.net"
194  }
195  ["version"]=>
196  int(2)
197  ["serialNumber"]=>
198  string(20) "12593567369101004962"
199  ["serialNumberHex"]=>
200  string(16) "AEC556CC723750A2"
201  ["validFrom"]=>
202  string(13) "080630102843Z"
203  ["validTo"]=>
204  string(13) "080730102843Z"
205  ["validFrom_time_t"]=>
206  int(1214821723)
207  ["validTo_time_t"]=>
208  int(1217413723)
209  ["signatureTypeSN"]=>
210  string(8) "RSA-SHA1"
211  ["signatureTypeLN"]=>
212  string(21) "sha1WithRSAEncryption"
213  ["signatureTypeNID"]=>
214  int(65)
215  ["purposes"]=>
216  array(9) {
217    [1]=>
218    array(3) {
219      [0]=>
220      bool(true)
221      [1]=>
222      bool(true)
223      [2]=>
224      string(10) "SSL client"
225    }
226    [2]=>
227    array(3) {
228      [0]=>
229      bool(true)
230      [1]=>
231      bool(true)
232      [2]=>
233      string(10) "SSL server"
234    }
235    [3]=>
236    array(3) {
237      [0]=>
238      bool(true)
239      [1]=>
240      bool(true)
241      [2]=>
242      string(19) "Netscape SSL server"
243    }
244    [4]=>
245    array(3) {
246      [0]=>
247      bool(true)
248      [1]=>
249      bool(true)
250      [2]=>
251      string(14) "S/MIME signing"
252    }
253    [5]=>
254    array(3) {
255      [0]=>
256      bool(true)
257      [1]=>
258      bool(true)
259      [2]=>
260      string(17) "S/MIME encryption"
261    }
262    [6]=>
263    array(3) {
264      [0]=>
265      bool(true)
266      [1]=>
267      bool(true)
268      [2]=>
269      string(11) "CRL signing"
270    }
271    [7]=>
272    array(3) {
273      [0]=>
274      bool(true)
275      [1]=>
276      bool(true)
277      [2]=>
278      string(11) "Any Purpose"
279    }
280    [8]=>
281    array(3) {
282      [0]=>
283      bool(true)
284      [1]=>
285      bool(true)
286      [2]=>
287      string(11) "OCSP helper"
288    }
289    [9]=>
290    array(3) {
291      [0]=>
292      bool(false)
293      [1]=>
294      bool(true)
295      [2]=>
296      string(18) "Time Stamp signing"
297    }
298  }
299  ["extensions"]=>
300  array(3) {
301    ["subjectKeyIdentifier"]=>
302    string(59) "DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D"
303    ["authorityKeyIdentifier"]=>
304    string(202) "keyid:DB:7E:40:72:BD:5C:35:85:EC:29:29:81:12:E8:62:68:6A:B7:3F:7D
305DirName:/C=BR/ST=Rio Grande do Sul/L=Porto Alegre/CN=Henrique do N. Angelo/emailAddress=hnangelo@php.net
306serial:AE:C5:56:CC:72:37:50:A2
307"
308    ["basicConstraints"]=>
309    string(7) "CA:TRUE"
310  }
311}
312