Skip to content

Commit 04b864e

Browse files
authored
Fix GH-13806: openssl_x509_parse_basic test fails with OpenSSL 3.2+ (#13961)
Closes GH-13961
1 parent cc46a4e commit 04b864e

File tree

2 files changed

+335
-0
lines changed

2 files changed

+335
-0
lines changed

ext/openssl/tests/openssl_x509_parse_basic.phpt

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

0 commit comments

Comments
 (0)