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