]>
Commit | Line | Data |
---|---|---|
88b8a527 RL |
1 | #! /usr/bin/perl |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
6 | use POSIX; | |
7 | use File::Spec; | |
8 | use File::Copy; | |
42e0ccdf | 9 | use OpenSSL::Test qw/:DEFAULT with bldtop_file srctop_file cmdstr/; |
340166a9 | 10 | use OpenSSL::Test::Utils; |
88b8a527 RL |
11 | |
12 | setup("test_ssl"); | |
13 | ||
ad87a3dc MC |
14 | $ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf"); |
15 | ||
6b01bed2 VD |
16 | my ($no_rsa, $no_dsa, $no_dh, $no_ec, $no_srp, $no_psk, |
17 | $no_ssl3, $no_tls1, $no_tls1_1, $no_tls1_2, | |
dd696a55 | 18 | $no_dtls, $no_dtls1, $no_dtls1_2, $no_ct) = |
90d48e5e RL |
19 | anydisabled qw/rsa dsa dh ec srp psk |
20 | ssl3 tls1 tls1_1 tls1_2 | |
dd696a55 | 21 | dtls dtls1 dtls1_2 ct/; |
90d48e5e RL |
22 | my $no_anytls = alldisabled(available_protocols("tls")); |
23 | my $no_anydtls = alldisabled(available_protocols("dtls")); | |
3ea75c63 RL |
24 | |
25 | plan skip_all => "No SSL/TLS/DTLS protocol is support by this OpenSSL build" | |
26 | if $no_anytls && $no_anydtls; | |
340166a9 | 27 | |
88b8a527 RL |
28 | my $digest = "-sha1"; |
29 | my @reqcmd = ("openssl", "req"); | |
30 | my @x509cmd = ("openssl", "x509", $digest); | |
31 | my @verifycmd = ("openssl", "verify"); | |
42e0ccdf | 32 | my $dummycnf = srctop_file("apps", "openssl.cnf"); |
88b8a527 RL |
33 | |
34 | my $CAkey = "keyCA.ss"; | |
35 | my $CAcert="certCA.ss"; | |
36 | my $CAserial="certCA.srl"; | |
37 | my $CAreq="reqCA.ss"; | |
42e0ccdf | 38 | my $CAconf=srctop_file("test","CAss.cnf"); |
88b8a527 RL |
39 | my $CAreq2="req2CA.ss"; # temp |
40 | ||
42e0ccdf | 41 | my $Uconf=srctop_file("test","Uss.cnf"); |
88b8a527 RL |
42 | my $Ukey="keyU.ss"; |
43 | my $Ureq="reqU.ss"; | |
44 | my $Ucert="certU.ss"; | |
45 | ||
5beb63c4 RL |
46 | my $Dkey="keyD.ss"; |
47 | my $Dreq="reqD.ss"; | |
48 | my $Dcert="certD.ss"; | |
49 | ||
50 | my $Ekey="keyE.ss"; | |
51 | my $Ereq="reqE.ss"; | |
52 | my $Ecert="certE.ss"; | |
53 | ||
42e0ccdf | 54 | my $P1conf=srctop_file("test","P1ss.cnf"); |
88b8a527 RL |
55 | my $P1key="keyP1.ss"; |
56 | my $P1req="reqP1.ss"; | |
57 | my $P1cert="certP1.ss"; | |
58 | my $P1intermediate="tmp_intP1.ss"; | |
59 | ||
42e0ccdf | 60 | my $P2conf=srctop_file("test","P2ss.cnf"); |
88b8a527 RL |
61 | my $P2key="keyP2.ss"; |
62 | my $P2req="reqP2.ss"; | |
63 | my $P2cert="certP2.ss"; | |
64 | my $P2intermediate="tmp_intP2.ss"; | |
65 | ||
b7dffce0 KR |
66 | my $server_sess="server.ss"; |
67 | my $client_sess="client.ss"; | |
68 | ||
453dfd8d EK |
69 | # ssltest.c is deprecated in favour of the new framework in ssl_test.c |
70 | # If you're adding tests here, you probably want to convert them to the | |
71 | # new format in ssl_test.c and add recipes to 80-test_ssl_new.t instead. | |
88b8a527 RL |
72 | plan tests => |
73 | 1 # For testss | |
74 | + 1 # For ssltest -test_cipherlist | |
453dfd8d | 75 | + 14 # For the first testssl |
49b147f8 RL |
76 | + 16 # For the first testsslproxy |
77 | + 16 # For the second testsslproxy | |
88b8a527 RL |
78 | ; |
79 | ||
80 | subtest 'test_ss' => sub { | |
81 | if (testss()) { | |
82 | open OUT, ">", "intP1.ss"; | |
83 | copy($CAcert, \*OUT); copy($Ucert, \*OUT); | |
84 | close OUT; | |
85 | ||
86 | open OUT, ">", "intP2.ss"; | |
87 | copy($CAcert, \*OUT); copy($Ucert, \*OUT); copy($P1cert, \*OUT); | |
88 | close OUT; | |
89 | } | |
90 | }; | |
91 | ||
92 | my $check = ok(run(test(["ssltest","-test_cipherlist"])), "running ssltest"); | |
93 | ||
94 | SKIP: { | |
95 | skip "ssltest ended with error, skipping the rest", 3 | |
96 | if !$check; | |
97 | ||
98 | note('test_ssl -- key U'); | |
99 | testssl("keyU.ss", $Ucert, $CAcert); | |
100 | ||
101 | note('test_ssl -- key P1'); | |
49b147f8 | 102 | testsslproxy("keyP1.ss", "certP1.ss", "intP1.ss", "AB"); |
88b8a527 RL |
103 | |
104 | note('test_ssl -- key P2'); | |
49b147f8 | 105 | testsslproxy("keyP2.ss", "certP2.ss", "intP2.ss", "BC"); |
88b8a527 RL |
106 | } |
107 | ||
108 | # ----------- | |
109 | # subtest functions | |
110 | sub testss { | |
111 | open RND, ">>", ".rnd"; | |
112 | print RND "string to make the random number generator think it has entropy"; | |
113 | close RND; | |
114 | ||
5beb63c4 | 115 | my @req_dsa = ("-newkey", |
42e0ccdf | 116 | "dsa:".srctop_file("apps", "dsa1024.pem")); |
88b8a527 | 117 | my @req_new; |
340166a9 | 118 | if ($no_rsa) { |
5beb63c4 | 119 | @req_new = @req_dsa; |
88b8a527 RL |
120 | } else { |
121 | @req_new = ("-new"); | |
122 | } | |
123 | ||
5beb63c4 | 124 | plan tests => 17; |
88b8a527 RL |
125 | |
126 | SKIP: { | |
5beb63c4 | 127 | skip 'failure', 16 unless |
88b8a527 RL |
128 | ok(run(app([@reqcmd, "-config", $CAconf, |
129 | "-out", $CAreq, "-keyout", $CAkey, | |
130 | @req_new])), | |
131 | 'make cert request'); | |
132 | ||
5beb63c4 | 133 | skip 'failure', 15 unless |
88b8a527 RL |
134 | ok(run(app([@x509cmd, "-CAcreateserial", "-in", $CAreq, "-days", "30", |
135 | "-req", "-out", $CAcert, "-signkey", $CAkey, | |
136 | "-extfile", $CAconf, "-extensions", "v3_ca"], | |
137 | stdout => "err.ss")), | |
138 | 'convert request into self-signed cert'); | |
139 | ||
5beb63c4 | 140 | skip 'failure', 14 unless |
88b8a527 RL |
141 | ok(run(app([@x509cmd, "-in", $CAcert, |
142 | "-x509toreq", "-signkey", $CAkey, "-out", $CAreq2], | |
143 | stdout => "err.ss")), | |
144 | 'convert cert into a cert request'); | |
145 | ||
5beb63c4 | 146 | skip 'failure', 13 unless |
88b8a527 RL |
147 | ok(run(app([@reqcmd, "-config", $dummycnf, |
148 | "-verify", "-in", $CAreq, "-noout"])), | |
149 | 'verify request 1'); | |
150 | ||
151 | ||
5beb63c4 | 152 | skip 'failure', 12 unless |
88b8a527 RL |
153 | ok(run(app([@reqcmd, "-config", $dummycnf, |
154 | "-verify", "-in", $CAreq2, "-noout"])), | |
155 | 'verify request 2'); | |
156 | ||
5beb63c4 | 157 | skip 'failure', 11 unless |
88b8a527 RL |
158 | ok(run(app([@verifycmd, "-CAfile", $CAcert, $CAcert])), |
159 | 'verify signature'); | |
160 | ||
5beb63c4 | 161 | skip 'failure', 10 unless |
88b8a527 RL |
162 | ok(run(app([@reqcmd, "-config", $Uconf, |
163 | "-out", $Ureq, "-keyout", $Ukey, @req_new], | |
164 | stdout => "err.ss")), | |
165 | 'make a user cert request'); | |
166 | ||
5beb63c4 | 167 | skip 'failure', 9 unless |
88b8a527 RL |
168 | ok(run(app([@x509cmd, "-CAcreateserial", "-in", $Ureq, "-days", "30", |
169 | "-req", "-out", $Ucert, | |
170 | "-CA", $CAcert, "-CAkey", $CAkey, "-CAserial", $CAserial, | |
171 | "-extfile", $Uconf, "-extensions", "v3_ee"], | |
172 | stdout => "err.ss")) | |
173 | && run(app([@verifycmd, "-CAfile", $CAcert, $Ucert])), | |
174 | 'sign user cert request'); | |
175 | ||
5beb63c4 | 176 | skip 'failure', 8 unless |
88b8a527 RL |
177 | ok(run(app([@x509cmd, |
178 | "-subject", "-issuer", "-startdate", "-enddate", | |
179 | "-noout", "-in", $Ucert])), | |
180 | 'Certificate details'); | |
181 | ||
5beb63c4 RL |
182 | skip 'failure', 7 unless |
183 | subtest 'DSA certificate creation' => sub { | |
184 | plan skip_all => "skipping DSA certificate creation" | |
340166a9 | 185 | if $no_dsa; |
5beb63c4 RL |
186 | |
187 | plan tests => 4; | |
188 | ||
189 | SKIP: { | |
190 | $ENV{CN2} = "DSA Certificate"; | |
191 | skip 'failure', 3 unless | |
192 | ok(run(app([@reqcmd, "-config", $Uconf, | |
193 | "-out", $Dreq, "-keyout", $Dkey, | |
194 | @req_dsa], | |
195 | stdout => "err.ss")), | |
196 | "make a DSA user cert request"); | |
197 | skip 'failure', 2 unless | |
198 | ok(run(app([@x509cmd, "-CAcreateserial", | |
199 | "-in", $Dreq, | |
200 | "-days", "30", | |
201 | "-req", | |
202 | "-out", $Dcert, | |
203 | "-CA", $CAcert, "-CAkey", $CAkey, | |
204 | "-CAserial", $CAserial, | |
205 | "-extfile", $Uconf, | |
206 | "-extensions", "v3_ee_dsa"], | |
207 | stdout => "err.ss")), | |
208 | "sign DSA user cert request"); | |
209 | skip 'failure', 1 unless | |
210 | ok(run(app([@verifycmd, "-CAfile", $CAcert, $Dcert])), | |
211 | "verify DSA user cert"); | |
212 | skip 'failure', 0 unless | |
213 | ok(run(app([@x509cmd, | |
214 | "-subject", "-issuer", | |
215 | "-startdate", "-enddate", "-noout", | |
216 | "-in", $Dcert])), | |
217 | "DSA Certificate details"); | |
218 | } | |
219 | }; | |
220 | ||
221 | skip 'failure', 6 unless | |
222 | subtest 'ECDSA/ECDH certificate creation' => sub { | |
223 | plan skip_all => "skipping ECDSA/ECDH certificate creation" | |
340166a9 | 224 | if $no_ec; |
5beb63c4 RL |
225 | |
226 | plan tests => 5; | |
227 | ||
228 | SKIP: { | |
229 | $ENV{CN2} = "ECDSA Certificate"; | |
230 | skip 'failure', 4 unless | |
231 | ok(run(app(["openssl", "ecparam", "-name", "P-256", | |
232 | "-out", "ecp.ss"])), | |
233 | "make EC parameters"); | |
234 | skip 'failure', 3 unless | |
235 | ok(run(app([@reqcmd, "-config", $Uconf, | |
236 | "-out", $Ereq, "-keyout", $Ekey, | |
237 | "-newkey", "ec:ecp.ss"], | |
238 | stdout => "err.ss")), | |
239 | "make a ECDSA/ECDH user cert request"); | |
240 | skip 'failure', 2 unless | |
241 | ok(run(app([@x509cmd, "-CAcreateserial", | |
242 | "-in", $Ereq, | |
243 | "-days", "30", | |
244 | "-req", | |
245 | "-out", $Ecert, | |
246 | "-CA", $CAcert, "-CAkey", $CAkey, | |
247 | "-CAserial", $CAserial, | |
248 | "-extfile", $Uconf, | |
249 | "-extensions", "v3_ee_ec"], | |
250 | stdout => "err.ss")), | |
251 | "sign ECDSA/ECDH user cert request"); | |
252 | skip 'failure', 1 unless | |
253 | ok(run(app([@verifycmd, "-CAfile", $CAcert, $Ecert])), | |
254 | "verify ECDSA/ECDH user cert"); | |
255 | skip 'failure', 0 unless | |
256 | ok(run(app([@x509cmd, | |
257 | "-subject", "-issuer", | |
258 | "-startdate", "-enddate", "-noout", | |
259 | "-in", $Ecert])), | |
260 | "ECDSA Certificate details"); | |
261 | } | |
262 | }; | |
88b8a527 RL |
263 | |
264 | skip 'failure', 5 unless | |
265 | ok(run(app([@reqcmd, "-config", $P1conf, | |
266 | "-out", $P1req, "-keyout", $P1key, @req_new], | |
267 | stdout => "err.ss")), | |
268 | 'make a proxy cert request'); | |
269 | ||
270 | ||
271 | skip 'failure', 4 unless | |
272 | ok(run(app([@x509cmd, "-CAcreateserial", "-in", $P1req, "-days", "30", | |
273 | "-req", "-out", $P1cert, | |
274 | "-CA", $Ucert, "-CAkey", $Ukey, | |
275 | "-extfile", $P1conf, "-extensions", "v3_proxy"], | |
276 | stdout => "err.ss")), | |
277 | 'sign proxy with user cert'); | |
278 | ||
279 | copy($Ucert, $P1intermediate); | |
280 | run(app([@verifycmd, "-CAfile", $CAcert, | |
281 | "-untrusted", $P1intermediate, $P1cert])); | |
282 | ok(run(app([@x509cmd, | |
283 | "-subject", "-issuer", "-startdate", "-enddate", | |
284 | "-noout", "-in", $P1cert])), | |
285 | 'Certificate details'); | |
286 | ||
287 | skip 'failure', 2 unless | |
288 | ok(run(app([@reqcmd, "-config", $P2conf, | |
289 | "-out", $P2req, "-keyout", $P2key, | |
290 | @req_new], | |
291 | stdout => "err.ss")), | |
292 | 'make another proxy cert request'); | |
293 | ||
294 | ||
295 | skip 'failure', 1 unless | |
296 | ok(run(app([@x509cmd, "-CAcreateserial", "-in", $P2req, "-days", "30", | |
297 | "-req", "-out", $P2cert, | |
298 | "-CA", $P1cert, "-CAkey", $P1key, | |
299 | "-extfile", $P2conf, "-extensions", "v3_proxy"], | |
300 | stdout => "err.ss")), | |
301 | 'sign second proxy cert request with the first proxy cert'); | |
302 | ||
303 | ||
304 | open OUT, ">", $P2intermediate; | |
305 | copy($Ucert, \*OUT); copy($P1cert, \*OUT); | |
306 | close OUT; | |
307 | run(app([@verifycmd, "-CAfile", $CAcert, | |
308 | "-untrusted", $P2intermediate, $P2cert])); | |
309 | ok(run(app([@x509cmd, | |
310 | "-subject", "-issuer", "-startdate", "-enddate", | |
311 | "-noout", "-in", $P2cert])), | |
312 | 'Certificate details'); | |
313 | } | |
314 | } | |
315 | ||
316 | sub testssl { | |
42e0ccdf RL |
317 | my $key = shift || bldtop_file("apps","server.pem"); |
318 | my $cert = shift || bldtop_file("apps","server.pem"); | |
88b8a527 | 319 | my $CAtmp = shift; |
42e0ccdf | 320 | my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", bldtop_dir("certs")); |
88b8a527 RL |
321 | my @extra = @_; |
322 | ||
323 | my @ssltest = ("ssltest", | |
5beb63c4 | 324 | "-s_key", $key, "-s_cert", $cert, |
88b8a527 RL |
325 | "-c_key", $key, "-c_cert", $cert); |
326 | ||
42e0ccdf | 327 | my $serverinfo = srctop_file("test","serverinfo.pem"); |
88b8a527 RL |
328 | |
329 | my $dsa_cert = 0; | |
330 | if (grep /DSA Public Key/, run(app(["openssl", "x509", "-in", $cert, | |
331 | "-text", "-noout"]), capture => 1)) { | |
332 | $dsa_cert = 1; | |
333 | } | |
334 | ||
335 | ||
dd696a55 | 336 | # plan tests => 11; |
88b8a527 RL |
337 | |
338 | subtest 'standard SSL tests' => sub { | |
339 | ###################################################################### | |
75d5bd4e | 340 | plan tests => 29; |
88b8a527 | 341 | |
3ea75c63 RL |
342 | SKIP: { |
343 | skip "SSLv3 is not supported by this OpenSSL build", 4 | |
344 | if disabled("ssl3"); | |
345 | ||
346 | ok(run(test([@ssltest, "-ssl3", @extra])), | |
347 | 'test sslv3'); | |
348 | ok(run(test([@ssltest, "-ssl3", "-server_auth", @CA, @extra])), | |
349 | 'test sslv3 with server authentication'); | |
350 | ok(run(test([@ssltest, "-ssl3", "-client_auth", @CA, @extra])), | |
351 | 'test sslv3 with client authentication'); | |
352 | ok(run(test([@ssltest, "-ssl3", "-server_auth", "-client_auth", @CA, @extra])), | |
353 | 'test sslv3 with both server and client authentication'); | |
354 | } | |
355 | ||
356 | SKIP: { | |
357 | skip "Neither SSLv3 nor any TLS version are supported by this OpenSSL build", 4 | |
358 | if $no_anytls; | |
359 | ||
360 | ok(run(test([@ssltest, @extra])), | |
361 | 'test sslv2/sslv3'); | |
362 | ok(run(test([@ssltest, "-server_auth", @CA, @extra])), | |
363 | 'test sslv2/sslv3 with server authentication'); | |
364 | ok(run(test([@ssltest, "-client_auth", @CA, @extra])), | |
365 | 'test sslv2/sslv3 with client authentication'); | |
366 | ok(run(test([@ssltest, "-server_auth", "-client_auth", @CA, @extra])), | |
367 | 'test sslv2/sslv3 with both server and client authentication'); | |
368 | } | |
369 | ||
370 | SKIP: { | |
371 | skip "SSLv3 is not supported by this OpenSSL build", 4 | |
372 | if disabled("ssl3"); | |
373 | ||
374 | ok(run(test([@ssltest, "-bio_pair", "-ssl3", @extra])), | |
375 | 'test sslv3 via BIO pair'); | |
376 | ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-server_auth", @CA, @extra])), | |
377 | 'test sslv3 with server authentication via BIO pair'); | |
378 | ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-client_auth", @CA, @extra])), | |
379 | 'test sslv3 with client authentication via BIO pair'); | |
380 | ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-server_auth", "-client_auth", @CA, @extra])), | |
381 | 'test sslv3 with both server and client authentication via BIO pair'); | |
382 | } | |
383 | ||
384 | SKIP: { | |
385 | skip "Neither SSLv3 nor any TLS version are supported by this OpenSSL build", 1 | |
386 | if $no_anytls; | |
387 | ||
388 | ok(run(test([@ssltest, "-bio_pair", @extra])), | |
389 | 'test sslv2/sslv3 via BIO pair'); | |
390 | } | |
391 | ||
392 | SKIP: { | |
393 | skip "DTLSv1 is not supported by this OpenSSL build", 4 | |
394 | if disabled("dtls1"); | |
395 | ||
396 | ok(run(test([@ssltest, "-dtls1", @extra])), | |
397 | 'test dtlsv1'); | |
398 | ok(run(test([@ssltest, "-dtls1", "-server_auth", @CA, @extra])), | |
88b8a527 | 399 | 'test dtlsv1 with server authentication'); |
3ea75c63 RL |
400 | ok(run(test([@ssltest, "-dtls1", "-client_auth", @CA, @extra])), |
401 | 'test dtlsv1 with client authentication'); | |
402 | ok(run(test([@ssltest, "-dtls1", "-server_auth", "-client_auth", @CA, @extra])), | |
403 | 'test dtlsv1 with both server and client authentication'); | |
404 | } | |
405 | ||
406 | SKIP: { | |
407 | skip "DTLSv1.2 is not supported by this OpenSSL build", 4 | |
408 | if disabled("dtls1_2"); | |
409 | ||
410 | ok(run(test([@ssltest, "-dtls12", @extra])), | |
411 | 'test dtlsv1.2'); | |
412 | ok(run(test([@ssltest, "-dtls12", "-server_auth", @CA, @extra])), | |
413 | 'test dtlsv1.2 with server authentication'); | |
414 | ok(run(test([@ssltest, "-dtls12", "-client_auth", @CA, @extra])), | |
415 | 'test dtlsv1.2 with client authentication'); | |
416 | ok(run(test([@ssltest, "-dtls12", "-server_auth", "-client_auth", @CA, @extra])), | |
417 | 'test dtlsv1.2 with both server and client authentication'); | |
418 | } | |
419 | ||
420 | SKIP: { | |
75d5bd4e | 421 | skip "Neither SSLv3 nor any TLS version are supported by this OpenSSL build", 8 |
3ea75c63 RL |
422 | if $no_anytls; |
423 | ||
424 | SKIP: { | |
425 | skip "skipping test of sslv2/sslv3 w/o (EC)DHE test", 1 if $dsa_cert; | |
426 | ||
427 | ok(run(test([@ssltest, "-bio_pair", "-no_dhe", "-no_ecdhe", @extra])), | |
428 | 'test sslv2/sslv3 w/o (EC)DHE via BIO pair'); | |
429 | } | |
430 | ||
431 | ok(run(test([@ssltest, "-bio_pair", "-dhe1024dsa", "-v", @extra])), | |
432 | 'test sslv2/sslv3 with 1024bit DHE via BIO pair'); | |
433 | ok(run(test([@ssltest, "-bio_pair", "-server_auth", @CA, @extra])), | |
434 | 'test sslv2/sslv3 with server authentication'); | |
435 | ok(run(test([@ssltest, "-bio_pair", "-client_auth", @CA, @extra])), | |
436 | 'test sslv2/sslv3 with client authentication via BIO pair'); | |
437 | ok(run(test([@ssltest, "-bio_pair", "-server_auth", "-client_auth", @CA, @extra])), | |
438 | 'test sslv2/sslv3 with both client and server authentication via BIO pair'); | |
439 | ok(run(test([@ssltest, "-bio_pair", "-server_auth", "-client_auth", "-app_verify", @CA, @extra])), | |
440 | 'test sslv2/sslv3 with both client and server authentication via BIO pair and app verify'); | |
75d5bd4e | 441 | |
b7be6d22 RL |
442 | SKIP: { |
443 | skip "No IPv4 available on this machine", 1 | |
f9e55034 | 444 | unless !disabled("sock") && have_IPv4(); |
b7be6d22 RL |
445 | ok(run(test([@ssltest, "-ipv4", @extra])), |
446 | 'test TLS via IPv4'); | |
447 | } | |
448 | ||
449 | SKIP: { | |
450 | skip "No IPv6 available on this machine", 1 | |
f9e55034 | 451 | unless !disabled("sock") && have_IPv6(); |
b7be6d22 RL |
452 | ok(run(test([@ssltest, "-ipv6", @extra])), |
453 | 'test TLS via IPv6'); | |
454 | } | |
455 | } | |
88b8a527 RL |
456 | }; |
457 | ||
458 | subtest "Testing ciphersuites" => sub { | |
459 | ||
5beb63c4 RL |
460 | my @exkeys = (); |
461 | my $ciphers = "-EXP:-PSK:-SRP:-kDH:-kECDHe"; | |
462 | ||
340166a9 | 463 | if ($no_dh) { |
5beb63c4 RL |
464 | note "skipping DHE tests\n"; |
465 | $ciphers .= ":-kDHE"; | |
466 | } | |
340166a9 | 467 | if ($no_dsa) { |
5beb63c4 RL |
468 | note "skipping DSA tests\n"; |
469 | $ciphers .= ":-aDSA"; | |
470 | } else { | |
471 | push @exkeys, "-s_cert", "certD.ss", "-s_key", "keyD.ss"; | |
472 | } | |
473 | ||
340166a9 | 474 | if ($no_ec) { |
5beb63c4 RL |
475 | note "skipping EC tests\n"; |
476 | $ciphers .= ":!aECDSA:!kECDH"; | |
477 | } else { | |
478 | push @exkeys, "-s_cert", "certE.ss", "-s_key", "keyE.ss"; | |
479 | } | |
88b8a527 | 480 | |
6b01bed2 | 481 | my @protocols = (); |
3ea75c63 | 482 | # FIXME: I feel unsure about the following line, is that really just TLSv1.2, or is it all of the SSLv3/TLS protocols? |
6b01bed2 VD |
483 | push(@protocols, "TLSv1.2") unless $no_tls1_2; |
484 | push(@protocols, "SSLv3") unless $no_ssl3; | |
88b8a527 RL |
485 | my $protocolciphersuitcount = 0; |
486 | my %ciphersuites = | |
487 | map { my @c = | |
488 | map { split(/:/, $_) } | |
5beb63c4 RL |
489 | run(app(["openssl", "ciphers", "${_}:$ciphers"]), |
490 | capture => 1); | |
4ada8be2 | 491 | map { s/\R//; } @c; # chomp @c; |
88b8a527 RL |
492 | $protocolciphersuitcount += scalar @c; |
493 | $_ => [ @c ] } @protocols; | |
494 | ||
49dc5404 RL |
495 | plan skip_all => "None of the ciphersuites to test are available in this OpenSSL build" |
496 | if $protocolciphersuitcount + scalar(@protocols) == 0; | |
497 | ||
5beb63c4 RL |
498 | # The count of protocols is because in addition to the ciphersuits |
499 | # we got above, we're running a weak DH test for each protocol | |
500 | plan tests => $protocolciphersuitcount + scalar(@protocols); | |
88b8a527 RL |
501 | |
502 | foreach my $protocol (@protocols) { | |
503 | note "Testing ciphersuites for $protocol"; | |
504 | foreach my $cipher (@{$ciphersuites{$protocol}}) { | |
5beb63c4 | 505 | ok(run(test([@ssltest, @exkeys, "-cipher", $cipher, |
88b8a527 RL |
506 | $protocol eq "SSLv3" ? ("-ssl3") : ()])), |
507 | "Testing $cipher"); | |
508 | } | |
5beb63c4 RL |
509 | is(run(test([@ssltest, |
510 | "-s_cipher", "EDH", | |
511 | "-c_cipher", 'EDH:@SECLEVEL=1', | |
512 | "-dhe512", | |
513 | $protocol eq "SSLv3" ? ("-ssl3") : ()])), 0, | |
514 | "testing connection with weak DH, expecting failure"); | |
88b8a527 RL |
515 | } |
516 | }; | |
517 | ||
518 | subtest 'RSA/(EC)DHE/PSK tests' => sub { | |
519 | ###################################################################### | |
520 | ||
521 | plan tests => 5; | |
522 | ||
3ea75c63 RL |
523 | SKIP: { |
524 | skip "TLSv1.0 is not supported by this OpenSSL build", 5 | |
525 | if $no_tls1; | |
88b8a527 | 526 | |
3ea75c63 RL |
527 | SKIP: { |
528 | skip "skipping anonymous DH tests", 1 | |
529 | if ($no_dh); | |
88b8a527 | 530 | |
3ea75c63 RL |
531 | ok(run(test([@ssltest, "-v", "-bio_pair", "-tls1", "-cipher", "ADH", "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])), |
532 | 'test tlsv1 with 1024bit anonymous DH, multiple handshakes'); | |
533 | } | |
88b8a527 | 534 | |
3ea75c63 RL |
535 | SKIP: { |
536 | skip "skipping RSA tests", 2 | |
537 | if $no_rsa; | |
88b8a527 | 538 | |
42e0ccdf | 539 | ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", srctop_file("apps","server2.pem"), "-no_dhe", "-no_ecdhe", "-num", "10", "-f", "-time", @extra])), |
3ea75c63 | 540 | 'test tlsv1 with 1024bit RSA, no (EC)DHE, multiple handshakes'); |
88b8a527 | 541 | |
3ea75c63 RL |
542 | skip "skipping RSA+DHE tests", 1 |
543 | if $no_dh; | |
544 | ||
42e0ccdf | 545 | ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", srctop_file("apps","server2.pem"), "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])), |
3ea75c63 RL |
546 | 'test tlsv1 with 1024bit RSA, 1024bit DHE, multiple handshakes'); |
547 | } | |
548 | ||
549 | SKIP: { | |
550 | skip "skipping PSK tests", 2 | |
71a64af3 DSH |
551 | if ($no_psk); |
552 | ||
3ea75c63 RL |
553 | ok(run(test([@ssltest, "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])), |
554 | 'test tls1 with PSK'); | |
71a64af3 | 555 | |
3ea75c63 RL |
556 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])), |
557 | 'test tls1 with PSK via BIO pair'); | |
558 | } | |
559 | } | |
88b8a527 | 560 | |
88b8a527 RL |
561 | }; |
562 | ||
563 | subtest 'Next Protocol Negotiation Tests' => sub { | |
564 | ###################################################################### | |
565 | ||
566 | plan tests => 7; | |
567 | ||
3ea75c63 RL |
568 | SKIP: { |
569 | skip "TLSv1.0 is not supported by this OpenSSL build", 7 | |
570 | if $no_tls1; | |
571 | ||
572 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client"]))); | |
573 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_server"]))); | |
574 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_server_reject"]))); | |
575 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server_reject"]))); | |
576 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server"]))); | |
577 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server", "-num", "2"]))); | |
578 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server", "-num", "2", "-reuse"]))); | |
579 | } | |
88b8a527 RL |
580 | }; |
581 | ||
582 | subtest 'Custom Extension tests' => sub { | |
583 | ###################################################################### | |
584 | ||
585 | plan tests => 1; | |
586 | ||
3ea75c63 | 587 | SKIP: { |
f006217b | 588 | skip "TLSv1.0 is not supported by this OpenSSL build", 1 |
3ea75c63 RL |
589 | if $no_tls1; |
590 | ||
591 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-custom_ext"])), | |
592 | 'test tls1 with custom extensions'); | |
593 | } | |
88b8a527 RL |
594 | }; |
595 | ||
596 | subtest 'Serverinfo tests' => sub { | |
597 | ###################################################################### | |
598 | ||
599 | plan tests => 5; | |
600 | ||
3ea75c63 RL |
601 | SKIP: { |
602 | skip "TLSv1.0 is not supported by this OpenSSL build", 5 | |
603 | if $no_tls1; | |
604 | ||
605 | note('echo test tls1 with serverinfo'); | |
606 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo]))); | |
607 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_sct"]))); | |
608 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_tack"]))); | |
609 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_sct", "-serverinfo_tack"]))); | |
610 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-custom_ext", "-serverinfo_file", $serverinfo, "-serverinfo_sct", "-serverinfo_tack"]))); | |
611 | } | |
88b8a527 RL |
612 | }; |
613 | ||
817cd0d5 TS |
614 | subtest 'SNI tests' => sub { |
615 | ||
616 | plan tests => 7; | |
617 | ||
618 | SKIP: { | |
619 | skip "TLSv1.x is not supported by this OpenSSL build", 7 | |
620 | if $no_tls1 && $no_tls1_1 && $no_tls1_2; | |
621 | ||
622 | ok(run(test([@ssltest, "-bio_pair", "-sn_client", "foo"]))); | |
623 | ok(run(test([@ssltest, "-bio_pair", "-sn_server1", "foo"]))); | |
624 | ok(run(test([@ssltest, "-bio_pair", "-sn_client", "foo", "-sn_server1", "foo", "-sn_expect1"]))); | |
625 | ok(run(test([@ssltest, "-bio_pair", "-sn_client", "foo", "-sn_server1", "bar", "-sn_expect1"]))); | |
626 | ok(run(test([@ssltest, "-bio_pair", "-sn_client", "foo", "-sn_server1", "foo", "-sn_server2", "bar", "-sn_expect1"]))); | |
627 | ok(run(test([@ssltest, "-bio_pair", "-sn_client", "bar", "-sn_server1", "foo", "-sn_server2", "bar", "-sn_expect2"]))); | |
628 | # Negative test - make sure it doesn't crash, and doesn't switch contexts | |
629 | ok(run(test([@ssltest, "-bio_pair", "-sn_client", "foobar", "-sn_server1", "foo", "-sn_server2", "bar", "-sn_expect1"]))); | |
630 | } | |
631 | }; | |
632 | ||
88b8a527 RL |
633 | subtest 'ALPN tests' => sub { |
634 | ###################################################################### | |
635 | ||
0351baae | 636 | plan tests => 13; |
88b8a527 | 637 | |
3ea75c63 | 638 | SKIP: { |
0351baae | 639 | skip "TLSv1.0 is not supported by this OpenSSL build", 13 |
3ea75c63 RL |
640 | if $no_tls1; |
641 | ||
06217867 EK |
642 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo"]))); |
643 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_server", "foo"]))); | |
3ea75c63 RL |
644 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo", "-alpn_server", "foo", "-alpn_expected", "foo"]))); |
645 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo,bar", "-alpn_server", "foo", "-alpn_expected", "foo"]))); | |
646 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "foo", "-alpn_expected", "foo"]))); | |
647 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "foo,bar", "-alpn_expected", "foo"]))); | |
648 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "bar,foo", "-alpn_expected", "bar"]))); | |
649 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo,bar", "-alpn_server", "bar,foo", "-alpn_expected", "bar"]))); | |
06217867 EK |
650 | |
651 | is(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo", "-alpn_server", "bar"])), 0, | |
652 | "Testing ALPN with protocol mismatch, expecting failure"); | |
653 | is(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "baz", "-alpn_server", "bar,foo"])), 0, | |
654 | "Testing ALPN with protocol mismatch, expecting failure"); | |
88b8a527 | 655 | |
817cd0d5 TS |
656 | # ALPN + SNI |
657 | ok(run(test([@ssltest, "-bio_pair", | |
658 | "-alpn_client", "foo,bar", "-sn_client", "alice", | |
659 | "-alpn_server1", "foo,123", "-sn_server1", "alice", | |
660 | "-alpn_server2", "bar,456", "-sn_server2", "bob", | |
661 | "-alpn_expected", "foo"]))); | |
662 | ok(run(test([@ssltest, "-bio_pair", | |
663 | "-alpn_client", "foo,bar", "-sn_client", "bob", | |
664 | "-alpn_server1", "foo,123", "-sn_server1", "alice", | |
665 | "-alpn_server2", "bar,456", "-sn_server2", "bob", | |
666 | "-alpn_expected", "bar"]))); | |
0351baae TS |
667 | ok(run(test([@ssltest, "-bio_pair", |
668 | "-alpn_client", "foo,bar", "-sn_client", "bob", | |
669 | "-alpn_server2", "bar,456", "-sn_server2", "bob", | |
670 | "-alpn_expected", "bar"]))); | |
817cd0d5 TS |
671 | } |
672 | }; | |
88b8a527 | 673 | |
817cd0d5 | 674 | subtest 'SRP tests' => sub { |
88b8a527 | 675 | |
817cd0d5 | 676 | plan tests => 4; |
88b8a527 | 677 | |
817cd0d5 TS |
678 | SKIP: { |
679 | skip "skipping SRP tests", 4 | |
680 | if $no_srp; | |
88b8a527 | 681 | |
817cd0d5 TS |
682 | ok(run(test([@ssltest, "-tls1", "-cipher", "SRP", "-srpuser", "test", "-srppass", "abc123"])), |
683 | 'test tls1 with SRP'); | |
684 | ||
685 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "SRP", "-srpuser", "test", "-srppass", "abc123"])), | |
686 | 'test tls1 with SRP via BIO pair'); | |
687 | ||
688 | ok(run(test([@ssltest, "-tls1", "-cipher", "aSRP", "-srpuser", "test", "-srppass", "abc123"])), | |
689 | 'test tls1 with SRP auth'); | |
690 | ||
691 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "aSRP", "-srpuser", "test", "-srppass", "abc123"])), | |
692 | 'test tls1 with SRP auth via BIO pair'); | |
88b8a527 RL |
693 | } |
694 | }; | |
695 | ||
696 | subtest 'Multi-buffer tests' => sub { | |
697 | ###################################################################### | |
698 | ||
699 | plan tests => 2; | |
700 | ||
3ea75c63 RL |
701 | SKIP: { |
702 | skip "Neither SSLv3 nor any TLS version are supported by this OpenSSL build", 2 | |
703 | if $no_anytls; | |
704 | ||
705 | skip "skipping multi-buffer tests", 2 | |
706 | if @extra || (POSIX::uname())[4] ne "x86_64"; | |
707 | ||
708 | ok(run(test([@ssltest, "-cipher", "AES128-SHA", "-bytes", "8m"]))); | |
709 | ||
710 | # We happen to know that AES128-SHA256 is TLSv1.2 only... for now. | |
711 | skip "TLSv1.2 is not supported by this OpenSSL configuration", 1 | |
712 | if $no_tls1_2; | |
713 | ||
714 | ok(run(test([@ssltest, "-cipher", "AES128-SHA256", "-bytes", "8m"]))); | |
88b8a527 RL |
715 | } |
716 | }; | |
7946ab33 | 717 | |
6b01bed2 VD |
718 | subtest 'DTLS Version min/max tests' => sub { |
719 | my @protos; | |
720 | push(@protos, "dtls1") unless ($no_dtls1 || $no_dtls); | |
721 | push(@protos, "dtls1.2") unless ($no_dtls1_2 || $no_dtls); | |
722 | my @minprotos = (undef, @protos); | |
723 | my @maxprotos = (@protos, undef); | |
724 | my @shdprotos = (@protos, $protos[$#protos]); | |
725 | my $n = ((@protos+2) * (@protos+3))/2 - 2; | |
726 | my $ntests = $n * $n; | |
727 | plan tests => $ntests; | |
835894d1 | 728 | SKIP: { |
6b01bed2 VD |
729 | skip "DTLS disabled", 1 if $ntests == 1; |
730 | ||
731 | my $should; | |
732 | for (my $smin = 0; $smin < @minprotos; ++$smin) { | |
733 | for (my $smax = $smin ? $smin - 1 : 0; $smax < @maxprotos; ++$smax) { | |
734 | for (my $cmin = 0; $cmin < @minprotos; ++$cmin) { | |
735 | for (my $cmax = $cmin ? $cmin - 1 : 0; $cmax < @maxprotos; ++$cmax) { | |
736 | if ($cmax < $smin-1) { | |
737 | $should = "fail-server"; | |
738 | } elsif ($smax < $cmin-1) { | |
739 | $should = "fail-client"; | |
740 | } elsif ($cmax > $smax) { | |
741 | $should = $shdprotos[$smax]; | |
742 | } else { | |
743 | $should = $shdprotos[$cmax]; | |
744 | } | |
745 | ||
746 | my @args = (@ssltest, "-dtls"); | |
747 | push(@args, "-should_negotiate", $should); | |
748 | push(@args, "-server_min_proto", $minprotos[$smin]) | |
749 | if (defined($minprotos[$smin])); | |
750 | push(@args, "-server_max_proto", $maxprotos[$smax]) | |
751 | if (defined($maxprotos[$smax])); | |
752 | push(@args, "-client_min_proto", $minprotos[$cmin]) | |
753 | if (defined($minprotos[$cmin])); | |
754 | push(@args, "-client_max_proto", $maxprotos[$cmax]) | |
755 | if (defined($maxprotos[$cmax])); | |
756 | my $ok = run(test[@args]); | |
757 | if (! $ok) { | |
758 | print STDERR "\nsmin=$smin, smax=$smax, cmin=$cmin, cmax=$cmax\n"; | |
759 | print STDERR "\nFailed: @args\n"; | |
760 | } | |
761 | ok($ok); | |
835894d1 | 762 | }}}}} |
7946ab33 | 763 | }; |
dd696a55 | 764 | |
b7dffce0 KR |
765 | subtest 'TLS session reuse' => sub { |
766 | plan tests => 12; | |
767 | ||
768 | ok(run(test([@ssltest, "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
769 | ok(run(test([@ssltest, "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "tls1.2"]))); | |
770 | ok(run(test([@ssltest, "-server_max_proto", "tls1.1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "tls1.1"]))); | |
771 | ||
772 | ok(run(test([@ssltest, "-server_max_proto", "tls1.1", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
773 | ok(run(test([@ssltest, "-server_max_proto", "tls1.1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "tls1.1"]))); | |
774 | ok(run(test([@ssltest, "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "tls1.2"]))); | |
775 | ||
776 | ok(run(test([@ssltest, "-no_ticket", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
777 | ok(run(test([@ssltest, "-no_ticket", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "tls1.2"]))); | |
778 | ok(run(test([@ssltest, "-no_ticket", "-server_max_proto", "tls1.1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "tls1.1"]))); | |
779 | ||
780 | ok(run(test([@ssltest, "-no_ticket", "-server_max_proto", "tls1.1", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
781 | ok(run(test([@ssltest, "-no_ticket", "-server_max_proto", "tls1.1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "tls1.1"]))); | |
782 | ok(run(test([@ssltest, "-no_ticket", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "tls1.2"]))); | |
783 | }; | |
784 | ||
785 | subtest 'DTLS session reuse' => sub { | |
786 | plan tests => 12; | |
787 | SKIP: { | |
788 | skip "DTLS disabled", 12 if $no_dtls; | |
789 | ||
790 | ok(run(test([@ssltest, "-dtls", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
791 | ok(run(test([@ssltest, "-dtls", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "dtls1.2"]))); | |
792 | ok(run(test([@ssltest, "-dtls", "-server_max_proto", "dtls1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "dtls1"]))); | |
793 | ||
794 | ok(run(test([@ssltest, "-dtls", "-server_max_proto", "dtls1", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
795 | ok(run(test([@ssltest, "-dtls", "-server_max_proto", "dtls1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "dtls1"]))); | |
796 | ok(run(test([@ssltest, "-dtls", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "dtls1.2"]))); | |
797 | ||
798 | ok(run(test([@ssltest, "-dtls", "-no_ticket", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
799 | ok(run(test([@ssltest, "-dtls", "-no_ticket", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "dtls1.2"]))); | |
800 | ok(run(test([@ssltest, "-dtls", "-no_ticket", "-server_max_proto", "dtls1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "dtls1"]))); | |
801 | ||
802 | ok(run(test([@ssltest, "-dtls", "-no_ticket", "-server_max_proto", "dtls1", "-server_sess_out", $server_sess, "-client_sess_out", $client_sess]))); | |
803 | ok(run(test([@ssltest, "-dtls", "-no_ticket", "-server_max_proto", "dtls1", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "1", "-should_negotiate", "dtls1"]))); | |
804 | ok(run(test([@ssltest, "-dtls", "-no_ticket", "-server_sess_in", $server_sess, "-client_sess_in", $client_sess, "-should_reuse", "0", "-should_negotiate", "dtls1.2"]))); | |
805 | } | |
806 | }; | |
807 | ||
dd696a55 RP |
808 | subtest 'Certificate Transparency tests' => sub { |
809 | ###################################################################### | |
810 | ||
811 | plan tests => 3; | |
812 | ||
813 | SKIP: { | |
814 | skip "Certificate Transparency is not supported by this OpenSSL build", 3 | |
815 | if $no_ct; | |
816 | skip "TLSv1.0 is not supported by this OpenSSL build", 3 | |
817 | if $no_tls1; | |
818 | ||
819 | $ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf"); | |
820 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-noct"]))); | |
821 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-requestct"]))); | |
822 | # No SCTs provided, so this should fail. | |
823 | ok(run(test([@ssltest, "-bio_pair", "-tls1", "-requirect", | |
824 | "-should_negotiate", "fail-client"]))); | |
825 | } | |
826 | }; | |
827 | ||
88b8a527 RL |
828 | } |
829 | ||
830 | sub testsslproxy { | |
42e0ccdf RL |
831 | my $key = shift || srctop_file("apps","server.pem"); |
832 | my $cert = shift || srctop_file("apps","server.pem"); | |
49b147f8 | 833 | my $CAtmp = shift; |
42e0ccdf | 834 | my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", bldtop_dir("certs")); |
49b147f8 RL |
835 | my @extra = @_; |
836 | ||
837 | my @ssltest = ("ssltest", | |
838 | "-s_key", $key, "-s_cert", $cert, | |
839 | "-c_key", $key, "-c_cert", $cert); | |
88b8a527 RL |
840 | |
841 | # plan tests => 16; | |
842 | ||
843 | note('Testing a lot of proxy conditions.'); | |
49b147f8 RL |
844 | |
845 | # We happen to know that certP1.ss has policy letters "AB" and | |
846 | # certP2.ss has policy letters "BC". However, because certP2.ss | |
847 | # has certP1.ss as issuer, when it's used, both their policy | |
848 | # letters get combined into just "B". | |
849 | # The policy letter(s) then get filtered with the given auth letter | |
850 | # in the table below, and the result gets tested with the given | |
851 | # condition. For details, read ssltest.c | |
852 | # | |
853 | # certfilename => [ [ auth, cond, expected result ] ... ] | |
854 | my %expected = ( "certP1.ss" => [ [ [ 'A', 'A' ], 1 ], | |
855 | [ [ 'A', 'B' ], 0 ], | |
856 | [ [ 'A', 'C' ], 0 ], | |
857 | [ [ 'A', 'A|B&!C' ], 1 ], | |
858 | [ [ 'B', 'A' ], 0 ], | |
859 | [ [ 'B', 'B' ], 1 ], | |
860 | [ [ 'B', 'C' ], 0 ], | |
861 | [ [ 'B', 'A|B&!C' ], 1 ], | |
862 | [ [ 'C', 'A' ], 0 ], | |
863 | [ [ 'C', 'B' ], 0 ], | |
864 | [ [ 'C', 'C' ], 0 ], | |
865 | [ [ 'C', 'A|B&!C' ], 0 ], | |
866 | [ [ 'BC', 'A' ], 0 ], | |
867 | [ [ 'BC', 'B' ], 1 ], | |
868 | [ [ 'BC', 'C' ], 0 ], | |
869 | [ [ 'BC', 'A|B&!C' ], 1 ] ], | |
870 | "certP2.ss" => [ [ [ 'A', 'A' ], 0 ], | |
871 | [ [ 'A', 'B' ], 0 ], | |
872 | [ [ 'A', 'C' ], 0 ], | |
873 | [ [ 'A', 'A|B&!C' ], 0 ], | |
874 | [ [ 'B', 'A' ], 0 ], | |
875 | [ [ 'B', 'B' ], 1 ], | |
876 | [ [ 'B', 'C' ], 0 ], | |
877 | [ [ 'B', 'A|B&!C' ], 1 ], | |
878 | [ [ 'C', 'A' ], 0 ], | |
879 | [ [ 'C', 'B' ], 0 ], | |
880 | [ [ 'C', 'C' ], 0 ], | |
881 | [ [ 'C', 'A|B&!C' ], 0 ], | |
882 | [ [ 'BC', 'A' ], 0 ], | |
883 | [ [ 'BC', 'B' ], 1 ], | |
884 | [ [ 'BC', 'C' ], 0 ], | |
885 | [ [ 'BC', 'A|B&!C' ], 1 ] ] ); | |
886 | ||
3ea75c63 RL |
887 | SKIP: { |
888 | skip "Neither SSLv3 nor any TLS version are supported by this OpenSSL build", scalar(@{$expected{$cert}}) | |
889 | if $no_anytls; | |
890 | ||
891 | foreach (@{$expected{$cert}}) { | |
892 | my $auth = $_->[0]->[0]; | |
893 | my $cond = $_->[0]->[1]; | |
894 | my $res = $_->[1]; | |
895 | is(run(test([@ssltest, "-server_auth", @CA, | |
896 | "-proxy", "-proxy_auth", $auth, | |
897 | "-proxy_cond", $cond])), $res, | |
898 | "test tlsv1, server auth, proxy auth $auth and cond $cond (expect " | |
899 | .($res ? "success" : "failure").")"); | |
900 | } | |
88b8a527 RL |
901 | } |
902 | } |