]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/80-test_ssl.t
Change test recipes to use disabled()
[thirdparty/openssl.git] / test / recipes / 80-test_ssl.t
1 #! /usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use POSIX;
7 use File::Spec;
8 use File::Copy;
9 use OpenSSL::Test qw/:DEFAULT with top_file cmdstr/;
10 use OpenSSL::Test::Utils;
11
12 setup("test_ssl");
13
14 my ($no_rsa, $no_dsa, $no_dh, $no_ec, $no_srp, $no_psk) =
15 disabled qw/rsa dsa dh ec srp psk/;
16
17 my $digest = "-sha1";
18 my @reqcmd = ("openssl", "req");
19 my @x509cmd = ("openssl", "x509", $digest);
20 my @verifycmd = ("openssl", "verify");
21 my $dummycnf = top_file("apps", "openssl.cnf");
22
23 my $CAkey = "keyCA.ss";
24 my $CAcert="certCA.ss";
25 my $CAserial="certCA.srl";
26 my $CAreq="reqCA.ss";
27 my $CAconf=top_file("test","CAss.cnf");
28 my $CAreq2="req2CA.ss"; # temp
29
30 my $Uconf=top_file("test","Uss.cnf");
31 my $Ukey="keyU.ss";
32 my $Ureq="reqU.ss";
33 my $Ucert="certU.ss";
34
35 my $Dkey="keyD.ss";
36 my $Dreq="reqD.ss";
37 my $Dcert="certD.ss";
38
39 my $Ekey="keyE.ss";
40 my $Ereq="reqE.ss";
41 my $Ecert="certE.ss";
42
43 my $P1conf=top_file("test","P1ss.cnf");
44 my $P1key="keyP1.ss";
45 my $P1req="reqP1.ss";
46 my $P1cert="certP1.ss";
47 my $P1intermediate="tmp_intP1.ss";
48
49 my $P2conf=top_file("test","P2ss.cnf");
50 my $P2key="keyP2.ss";
51 my $P2req="reqP2.ss";
52 my $P2cert="certP2.ss";
53 my $P2intermediate="tmp_intP2.ss";
54
55 plan tests =>
56 1 # For testss
57 + 1 # For ssltest -test_cipherlist
58 + 8 # For the first testssl
59 + 16 # For the first testsslproxy
60 + 16 # For the second testsslproxy
61 ;
62
63 subtest 'test_ss' => sub {
64 if (testss()) {
65 open OUT, ">", "intP1.ss";
66 copy($CAcert, \*OUT); copy($Ucert, \*OUT);
67 close OUT;
68
69 open OUT, ">", "intP2.ss";
70 copy($CAcert, \*OUT); copy($Ucert, \*OUT); copy($P1cert, \*OUT);
71 close OUT;
72 }
73 };
74
75 my $check = ok(run(test(["ssltest","-test_cipherlist"])), "running ssltest");
76
77 SKIP: {
78 skip "ssltest ended with error, skipping the rest", 3
79 if !$check;
80
81 note('test_ssl -- key U');
82 testssl("keyU.ss", $Ucert, $CAcert);
83
84 note('test_ssl -- key P1');
85 testsslproxy("keyP1.ss", "certP1.ss", "intP1.ss", "AB");
86
87 note('test_ssl -- key P2');
88 testsslproxy("keyP2.ss", "certP2.ss", "intP2.ss", "BC");
89 }
90
91 # -----------
92 # subtest functions
93 sub testss {
94 open RND, ">>", ".rnd";
95 print RND "string to make the random number generator think it has entropy";
96 close RND;
97
98 my @req_dsa = ("-newkey",
99 "dsa:".File::Spec->catfile("..", "apps", "dsa1024.pem"));;
100 my @req_new;
101 if ($no_rsa) {
102 @req_new = @req_dsa;
103 } else {
104 @req_new = ("-new");
105 }
106
107 plan tests => 17;
108
109 SKIP: {
110 skip 'failure', 16 unless
111 ok(run(app([@reqcmd, "-config", $CAconf,
112 "-out", $CAreq, "-keyout", $CAkey,
113 @req_new])),
114 'make cert request');
115
116 skip 'failure', 15 unless
117 ok(run(app([@x509cmd, "-CAcreateserial", "-in", $CAreq, "-days", "30",
118 "-req", "-out", $CAcert, "-signkey", $CAkey,
119 "-extfile", $CAconf, "-extensions", "v3_ca"],
120 stdout => "err.ss")),
121 'convert request into self-signed cert');
122
123 skip 'failure', 14 unless
124 ok(run(app([@x509cmd, "-in", $CAcert,
125 "-x509toreq", "-signkey", $CAkey, "-out", $CAreq2],
126 stdout => "err.ss")),
127 'convert cert into a cert request');
128
129 skip 'failure', 13 unless
130 ok(run(app([@reqcmd, "-config", $dummycnf,
131 "-verify", "-in", $CAreq, "-noout"])),
132 'verify request 1');
133
134
135 skip 'failure', 12 unless
136 ok(run(app([@reqcmd, "-config", $dummycnf,
137 "-verify", "-in", $CAreq2, "-noout"])),
138 'verify request 2');
139
140 skip 'failure', 11 unless
141 ok(run(app([@verifycmd, "-CAfile", $CAcert, $CAcert])),
142 'verify signature');
143
144 skip 'failure', 10 unless
145 ok(run(app([@reqcmd, "-config", $Uconf,
146 "-out", $Ureq, "-keyout", $Ukey, @req_new],
147 stdout => "err.ss")),
148 'make a user cert request');
149
150 skip 'failure', 9 unless
151 ok(run(app([@x509cmd, "-CAcreateserial", "-in", $Ureq, "-days", "30",
152 "-req", "-out", $Ucert,
153 "-CA", $CAcert, "-CAkey", $CAkey, "-CAserial", $CAserial,
154 "-extfile", $Uconf, "-extensions", "v3_ee"],
155 stdout => "err.ss"))
156 && run(app([@verifycmd, "-CAfile", $CAcert, $Ucert])),
157 'sign user cert request');
158
159 skip 'failure', 8 unless
160 ok(run(app([@x509cmd,
161 "-subject", "-issuer", "-startdate", "-enddate",
162 "-noout", "-in", $Ucert])),
163 'Certificate details');
164
165 skip 'failure', 7 unless
166 subtest 'DSA certificate creation' => sub {
167 plan skip_all => "skipping DSA certificate creation"
168 if $no_dsa;
169
170 plan tests => 4;
171
172 SKIP: {
173 $ENV{CN2} = "DSA Certificate";
174 skip 'failure', 3 unless
175 ok(run(app([@reqcmd, "-config", $Uconf,
176 "-out", $Dreq, "-keyout", $Dkey,
177 @req_dsa],
178 stdout => "err.ss")),
179 "make a DSA user cert request");
180 skip 'failure', 2 unless
181 ok(run(app([@x509cmd, "-CAcreateserial",
182 "-in", $Dreq,
183 "-days", "30",
184 "-req",
185 "-out", $Dcert,
186 "-CA", $CAcert, "-CAkey", $CAkey,
187 "-CAserial", $CAserial,
188 "-extfile", $Uconf,
189 "-extensions", "v3_ee_dsa"],
190 stdout => "err.ss")),
191 "sign DSA user cert request");
192 skip 'failure', 1 unless
193 ok(run(app([@verifycmd, "-CAfile", $CAcert, $Dcert])),
194 "verify DSA user cert");
195 skip 'failure', 0 unless
196 ok(run(app([@x509cmd,
197 "-subject", "-issuer",
198 "-startdate", "-enddate", "-noout",
199 "-in", $Dcert])),
200 "DSA Certificate details");
201 }
202 };
203
204 skip 'failure', 6 unless
205 subtest 'ECDSA/ECDH certificate creation' => sub {
206 plan skip_all => "skipping ECDSA/ECDH certificate creation"
207 if $no_ec;
208
209 plan tests => 5;
210
211 SKIP: {
212 $ENV{CN2} = "ECDSA Certificate";
213 skip 'failure', 4 unless
214 ok(run(app(["openssl", "ecparam", "-name", "P-256",
215 "-out", "ecp.ss"])),
216 "make EC parameters");
217 skip 'failure', 3 unless
218 ok(run(app([@reqcmd, "-config", $Uconf,
219 "-out", $Ereq, "-keyout", $Ekey,
220 "-newkey", "ec:ecp.ss"],
221 stdout => "err.ss")),
222 "make a ECDSA/ECDH user cert request");
223 skip 'failure', 2 unless
224 ok(run(app([@x509cmd, "-CAcreateserial",
225 "-in", $Ereq,
226 "-days", "30",
227 "-req",
228 "-out", $Ecert,
229 "-CA", $CAcert, "-CAkey", $CAkey,
230 "-CAserial", $CAserial,
231 "-extfile", $Uconf,
232 "-extensions", "v3_ee_ec"],
233 stdout => "err.ss")),
234 "sign ECDSA/ECDH user cert request");
235 skip 'failure', 1 unless
236 ok(run(app([@verifycmd, "-CAfile", $CAcert, $Ecert])),
237 "verify ECDSA/ECDH user cert");
238 skip 'failure', 0 unless
239 ok(run(app([@x509cmd,
240 "-subject", "-issuer",
241 "-startdate", "-enddate", "-noout",
242 "-in", $Ecert])),
243 "ECDSA Certificate details");
244 }
245 };
246
247 skip 'failure', 5 unless
248 ok(run(app([@reqcmd, "-config", $P1conf,
249 "-out", $P1req, "-keyout", $P1key, @req_new],
250 stdout => "err.ss")),
251 'make a proxy cert request');
252
253
254 skip 'failure', 4 unless
255 ok(run(app([@x509cmd, "-CAcreateserial", "-in", $P1req, "-days", "30",
256 "-req", "-out", $P1cert,
257 "-CA", $Ucert, "-CAkey", $Ukey,
258 "-extfile", $P1conf, "-extensions", "v3_proxy"],
259 stdout => "err.ss")),
260 'sign proxy with user cert');
261
262 copy($Ucert, $P1intermediate);
263 run(app([@verifycmd, "-CAfile", $CAcert,
264 "-untrusted", $P1intermediate, $P1cert]));
265 ok(run(app([@x509cmd,
266 "-subject", "-issuer", "-startdate", "-enddate",
267 "-noout", "-in", $P1cert])),
268 'Certificate details');
269
270 skip 'failure', 2 unless
271 ok(run(app([@reqcmd, "-config", $P2conf,
272 "-out", $P2req, "-keyout", $P2key,
273 @req_new],
274 stdout => "err.ss")),
275 'make another proxy cert request');
276
277
278 skip 'failure', 1 unless
279 ok(run(app([@x509cmd, "-CAcreateserial", "-in", $P2req, "-days", "30",
280 "-req", "-out", $P2cert,
281 "-CA", $P1cert, "-CAkey", $P1key,
282 "-extfile", $P2conf, "-extensions", "v3_proxy"],
283 stdout => "err.ss")),
284 'sign second proxy cert request with the first proxy cert');
285
286
287 open OUT, ">", $P2intermediate;
288 copy($Ucert, \*OUT); copy($P1cert, \*OUT);
289 close OUT;
290 run(app([@verifycmd, "-CAfile", $CAcert,
291 "-untrusted", $P2intermediate, $P2cert]));
292 ok(run(app([@x509cmd,
293 "-subject", "-issuer", "-startdate", "-enddate",
294 "-noout", "-in", $P2cert])),
295 'Certificate details');
296 }
297 }
298
299 sub testssl {
300 my $key = shift || top_file("apps","server.pem");
301 my $cert = shift || top_file("apps","server.pem");
302 my $CAtmp = shift;
303 my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", top_dir("certs"));
304 my @extra = @_;
305
306 my @ssltest = ("ssltest",
307 "-s_key", $key, "-s_cert", $cert,
308 "-c_key", $key, "-c_cert", $cert);
309
310 my $serverinfo = top_file("test","serverinfo.pem");
311
312 my $dsa_cert = 0;
313 if (grep /DSA Public Key/, run(app(["openssl", "x509", "-in", $cert,
314 "-text", "-noout"]), capture => 1)) {
315 $dsa_cert = 1;
316 }
317
318
319 # plan tests => 7;
320
321 subtest 'standard SSL tests' => sub {
322 ######################################################################
323 plan tests => 27;
324
325 ok(run(test([@ssltest, "-ssl3", @extra])),
326 'test sslv3');
327 ok(run(test([@ssltest, "-ssl3", "-server_auth", @CA, @extra])),
328 'test sslv3 with server authentication');
329 ok(run(test([@ssltest, "-ssl3", "-client_auth", @CA, @extra])),
330 'test sslv3 with client authentication');
331 ok(run(test([@ssltest, "-ssl3", "-server_auth", "-client_auth", @CA, @extra])),
332 'test sslv3 with both server and client authentication');
333 ok(run(test([@ssltest, @extra])),
334 'test sslv2/sslv3');
335 ok(run(test([@ssltest, "-server_auth", @CA, @extra])),
336 'test sslv2/sslv3 with server authentication');
337 ok(run(test([@ssltest, "-client_auth", @CA, @extra])),
338 'test sslv2/sslv3 with client authentication');
339 ok(run(test([@ssltest, "-server_auth", "-client_auth", @CA, @extra])),
340 'test sslv2/sslv3 with both server and client authentication');
341 ok(run(test([@ssltest, "-bio_pair", "-ssl3", @extra])),
342 'test sslv3 via BIO pair');
343 ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-server_auth", @CA, @extra])),
344 'test sslv3 with server authentication via BIO pair');
345 ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-client_auth", @CA, @extra])),
346 'test sslv3 with client authentication via BIO pair');
347 ok(run(test([@ssltest, "-bio_pair", "-ssl3", "-server_auth", "-client_auth", @CA, @extra])),
348 'test sslv3 with both server and client authentication via BIO pair');
349 ok(run(test([@ssltest, "-bio_pair", @extra])),
350 'test sslv2/sslv3 via BIO pair');
351 ok(run(test([@ssltest, "-dtls1", @extra])),
352 'test dtlsv1');
353 ok(run(test([@ssltest, "-dtls1", "-server_auth", @CA, @extra])),
354 'test dtlsv1 with server authentication');
355 ok(run(test([@ssltest, "-dtls1", "-client_auth", @CA, @extra])),
356 'test dtlsv1 with client authentication');
357 ok(run(test([@ssltest, "-dtls1", "-server_auth", "-client_auth", @CA, @extra])),
358 'test dtlsv1 with both server and client authentication');
359 ok(run(test([@ssltest, "-dtls12", @extra])),
360 'test dtlsv1.2');
361 ok(run(test([@ssltest, "-dtls12", "-server_auth", @CA, @extra])),
362 'test dtlsv1.2 with server authentication');
363 ok(run(test([@ssltest, "-dtls12", "-client_auth", @CA, @extra])),
364 'test dtlsv1.2 with client authentication');
365 ok(run(test([@ssltest, "-dtls12", "-server_auth", "-client_auth", @CA, @extra])),
366 'test dtlsv1.2 with both server and client authentication');
367 {
368 SKIP: {
369 skip "skipping test of sslv2/sslv3 w/o (EC)DHE test", 1 if $dsa_cert;
370
371 ok(run(test([@ssltest, "-bio_pair", "-no_dhe", "-no_ecdhe", @extra])),
372 'test sslv2/sslv3 w/o (EC)DHE via BIO pair');
373 }
374 }
375 ok(run(test([@ssltest, "-bio_pair", "-dhe1024dsa", "-v", @extra])),
376 'test sslv2/sslv3 with 1024bit DHE via BIO pair');
377 ok(run(test([@ssltest, "-bio_pair", "-server_auth", @CA, @extra])),
378 'test sslv2/sslv3 with server authentication');
379 ok(run(test([@ssltest, "-bio_pair", "-client_auth", @CA, @extra])),
380 'test sslv2/sslv3 with client authentication via BIO pair');
381 ok(run(test([@ssltest, "-bio_pair", "-server_auth", "-client_auth", @CA, @extra])),
382 'test sslv2/sslv3 with both client and server authentication via BIO pair');
383 ok(run(test([@ssltest, "-bio_pair", "-server_auth", "-client_auth", "-app_verify", @CA, @extra])),
384 'test sslv2/sslv3 with both client and server authentication via BIO pair and app verify');
385 };
386
387 subtest "Testing ciphersuites" => sub {
388
389 my @exkeys = ();
390 my $ciphers = "-EXP:-PSK:-SRP:-kDH:-kECDHe";
391
392 if ($no_dh) {
393 note "skipping DHE tests\n";
394 $ciphers .= ":-kDHE";
395 }
396 if ($no_dsa) {
397 note "skipping DSA tests\n";
398 $ciphers .= ":-aDSA";
399 } else {
400 push @exkeys, "-s_cert", "certD.ss", "-s_key", "keyD.ss";
401 }
402
403 if ($no_ec) {
404 note "skipping EC tests\n";
405 $ciphers .= ":!aECDSA:!kECDH";
406 } else {
407 push @exkeys, "-s_cert", "certE.ss", "-s_key", "keyE.ss";
408 }
409
410 my @protocols = ("TLSv1.2", "SSLv3");
411 my $protocolciphersuitcount = 0;
412 my %ciphersuites =
413 map { my @c =
414 map { split(/:/, $_) }
415 run(app(["openssl", "ciphers", "${_}:$ciphers"]),
416 capture => 1);
417 chomp @c;
418 $protocolciphersuitcount += scalar @c;
419 $_ => [ @c ] } @protocols;
420
421 # The count of protocols is because in addition to the ciphersuits
422 # we got above, we're running a weak DH test for each protocol
423 plan tests => $protocolciphersuitcount + scalar(@protocols);
424
425 foreach my $protocol (@protocols) {
426 note "Testing ciphersuites for $protocol";
427 foreach my $cipher (@{$ciphersuites{$protocol}}) {
428 ok(run(test([@ssltest, @exkeys, "-cipher", $cipher,
429 $protocol eq "SSLv3" ? ("-ssl3") : ()])),
430 "Testing $cipher");
431 }
432 is(run(test([@ssltest,
433 "-s_cipher", "EDH",
434 "-c_cipher", 'EDH:@SECLEVEL=1',
435 "-dhe512",
436 $protocol eq "SSLv3" ? ("-ssl3") : ()])), 0,
437 "testing connection with weak DH, expecting failure");
438 }
439 };
440
441 subtest 'RSA/(EC)DHE/PSK tests' => sub {
442 ######################################################################
443
444 plan tests => 5;
445
446 {
447 SKIP: {
448 skip "skipping anonymous DH tests", 1
449 if ($no_dh);
450
451 ok(run(test([@ssltest, "-v", "-bio_pair", "-tls1", "-cipher", "ADH", "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])),
452 'test tlsv1 with 1024bit anonymous DH, multiple handshakes');
453 }
454 }
455
456 {
457 SKIP: {
458 skip "skipping RSA tests", 2
459 if $no_rsa;
460
461 ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", top_file("apps","server2.pem"), "-no_dhe", "-no_ecdhe", "-num", "10", "-f", "-time", @extra])),
462 'test tlsv1 with 1024bit RSA, no (EC)DHE, multiple handshakes');
463
464 skip "skipping RSA+DHE tests", 1
465 if $no_dh;
466
467 ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", top_file("apps","server2.pem"), "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])),
468 'test tlsv1 with 1024bit RSA, 1024bit DHE, multiple handshakes');
469 }
470 }
471 ok(run(test([@ssltest, "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])),
472 'test tls1 with PSK');
473
474 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "PSK", "-psk", "abc123", @extra])),
475 'test tls1 with PSK via BIO pair');
476 };
477
478 subtest 'Next Protocol Negotiation Tests' => sub {
479 ######################################################################
480
481 plan tests => 7;
482
483 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client"])));
484 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_server"])));
485 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_server_reject"])));
486 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server_reject"])));
487 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server"])));
488 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server", "-num", "2"])));
489 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-npn_client", "-npn_server", "-num", "2", "-reuse"])));
490 };
491
492 subtest 'Custom Extension tests' => sub {
493 ######################################################################
494
495 plan tests => 1;
496
497 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-custom_ext"])),
498 'test tls1 with custom extensions');
499 };
500
501 subtest 'Serverinfo tests' => sub {
502 ######################################################################
503
504 plan tests => 5;
505
506 note('echo test tls1 with serverinfo');
507 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo])));
508 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_sct"])));
509 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_tack"])));
510 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-serverinfo_file", $serverinfo, "-serverinfo_sct", "-serverinfo_tack"])));
511 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-custom_ext", "-serverinfo_file", $serverinfo, "-serverinfo_sct", "-serverinfo_tack"])));
512 };
513
514 subtest 'ALPN tests' => sub {
515 ######################################################################
516
517 plan tests => 12;
518
519 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo", "-alpn_server", "bar"])));
520 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo", "-alpn_server", "foo", "-alpn_expected", "foo"])));
521 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo,bar", "-alpn_server", "foo", "-alpn_expected", "foo"])));
522 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "foo", "-alpn_expected", "foo"])));
523 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "foo,bar", "-alpn_expected", "foo"])));
524 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "bar,foo", "-alpn_server", "bar,foo", "-alpn_expected", "bar"])));
525 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "foo,bar", "-alpn_server", "bar,foo", "-alpn_expected", "bar"])));
526 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-alpn_client", "baz", "-alpn_server", "bar,foo"])));
527
528 {
529 SKIP: {
530 skip "skipping SRP tests", 4
531 if $no_srp;
532
533 ok(run(test([@ssltest, "-tls1", "-cipher", "SRP", "-srpuser", "test", "-srppass", "abc123"])),
534 'test tls1 with SRP');
535
536 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "SRP", "-srpuser", "test", "-srppass", "abc123"])),
537 'test tls1 with SRP via BIO pair');
538
539 ok(run(test([@ssltest, "-tls1", "-cipher", "aSRP", "-srpuser", "test", "-srppass", "abc123"])),
540 'test tls1 with SRP auth');
541
542 ok(run(test([@ssltest, "-bio_pair", "-tls1", "-cipher", "aSRP", "-srpuser", "test", "-srppass", "abc123"])),
543 'test tls1 with SRP auth via BIO pair');
544 }
545 }
546 };
547
548 subtest 'Multi-buffer tests' => sub {
549 ######################################################################
550
551 plan tests => 2;
552
553 {
554 SKIP: {
555 skip "skipping multi-buffer tests", 2
556 if @extra || (POSIX::uname())[4] ne "x86_64";
557 ok(run(test([@ssltest, "-cipher", "AES128-SHA", "-bytes", "8m"])));
558 ok(run(test([@ssltest, "-cipher", "AES128-SHA256", "-bytes", "8m"])));
559 }
560 }
561 };
562 }
563
564 sub testsslproxy {
565 my $key = shift || top_file("apps","server.pem");
566 my $cert = shift || top_file("apps","server.pem");
567 my $CAtmp = shift;
568 my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", top_dir("certs"));
569 my @extra = @_;
570
571 my @ssltest = ("ssltest",
572 "-s_key", $key, "-s_cert", $cert,
573 "-c_key", $key, "-c_cert", $cert);
574
575 # plan tests => 16;
576
577 note('Testing a lot of proxy conditions.');
578
579 # We happen to know that certP1.ss has policy letters "AB" and
580 # certP2.ss has policy letters "BC". However, because certP2.ss
581 # has certP1.ss as issuer, when it's used, both their policy
582 # letters get combined into just "B".
583 # The policy letter(s) then get filtered with the given auth letter
584 # in the table below, and the result gets tested with the given
585 # condition. For details, read ssltest.c
586 #
587 # certfilename => [ [ auth, cond, expected result ] ... ]
588 my %expected = ( "certP1.ss" => [ [ [ 'A', 'A' ], 1 ],
589 [ [ 'A', 'B' ], 0 ],
590 [ [ 'A', 'C' ], 0 ],
591 [ [ 'A', 'A|B&!C' ], 1 ],
592 [ [ 'B', 'A' ], 0 ],
593 [ [ 'B', 'B' ], 1 ],
594 [ [ 'B', 'C' ], 0 ],
595 [ [ 'B', 'A|B&!C' ], 1 ],
596 [ [ 'C', 'A' ], 0 ],
597 [ [ 'C', 'B' ], 0 ],
598 [ [ 'C', 'C' ], 0 ],
599 [ [ 'C', 'A|B&!C' ], 0 ],
600 [ [ 'BC', 'A' ], 0 ],
601 [ [ 'BC', 'B' ], 1 ],
602 [ [ 'BC', 'C' ], 0 ],
603 [ [ 'BC', 'A|B&!C' ], 1 ] ],
604 "certP2.ss" => [ [ [ 'A', 'A' ], 0 ],
605 [ [ 'A', 'B' ], 0 ],
606 [ [ 'A', 'C' ], 0 ],
607 [ [ 'A', 'A|B&!C' ], 0 ],
608 [ [ 'B', 'A' ], 0 ],
609 [ [ 'B', 'B' ], 1 ],
610 [ [ 'B', 'C' ], 0 ],
611 [ [ 'B', 'A|B&!C' ], 1 ],
612 [ [ 'C', 'A' ], 0 ],
613 [ [ 'C', 'B' ], 0 ],
614 [ [ 'C', 'C' ], 0 ],
615 [ [ 'C', 'A|B&!C' ], 0 ],
616 [ [ 'BC', 'A' ], 0 ],
617 [ [ 'BC', 'B' ], 1 ],
618 [ [ 'BC', 'C' ], 0 ],
619 [ [ 'BC', 'A|B&!C' ], 1 ] ] );
620
621 foreach (@{$expected{$cert}}) {
622 my $auth = $_->[0]->[0];
623 my $cond = $_->[0]->[1];
624 my $res = $_->[1];
625 is(run(test([@ssltest, "-ssl3", "-server_auth", @CA,
626 "-proxy", "-proxy_auth", $auth,
627 "-proxy_cond", $cond])), $res,
628 "test tlsv1, server auth, proxy auth $auth and cond $cond (expect "
629 .($res ? "success" : "failure").")");
630 }
631 }