Port remaining old DTLS tests
[openssl.git] / test / ssl-tests / 04-client_auth.conf.in
1 # -*- mode: perl; -*-
2
3 ## SSL test configurations
4
5 package ssltests;
6
7 use strict;
8 use warnings;
9
10 use OpenSSL::Test;
11 use OpenSSL::Test::Utils qw(anydisabled);
12 setup("no_test_here");
13
14 # We test version-flexible negotiation (undef) and each protocol version.
15 my @protocols = (undef, "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2", "DTLSv1", "DTLSv1.2");
16
17 my @is_disabled = (0);
18 push @is_disabled, anydisabled("ssl3", "tls1", "tls1_1", "tls1_2", "dtls1", "dtls1_2");
19
20 our @tests = ();
21
22 sub generate_tests() {
23     foreach (0..$#protocols) {
24         my $protocol = $protocols[$_];
25         my $protocol_name = $protocol || "flex";
26         my $caalert;
27         my $method;
28         if (!$is_disabled[$_]) {
29             if ($protocol_name eq "SSLv3") {
30                 $caalert = "BadCertificate";
31             } else {
32                 $caalert = "UnknownCA";
33             }
34             if ($protocol_name =~ m/^DTLS/) {
35                 $method = "DTLS";
36             }
37             my $clihash;
38             my $clisigtype;
39             my $clisigalgs;
40             # TODO(TLS1.3) add TLSv1.3 versions
41             if ($protocol_name eq "TLSv1.2") {
42                 $clihash = "SHA256";
43                 $clisigtype = "RSA";
44                 $clisigalgs = "SHA256+RSA";
45             }
46             # Sanity-check simple handshake.
47             push @tests, {
48                 name => "server-auth-${protocol_name}",
49                 server => {
50                     "MinProtocol" => $protocol,
51                     "MaxProtocol" => $protocol
52                 },
53                 client => {
54                     "MinProtocol" => $protocol,
55                     "MaxProtocol" => $protocol
56                 },
57                 test   => {
58                     "ExpectedResult" => "Success",
59                     "Method" => $method,
60                 },
61             };
62
63             # Handshake with client cert requested but not required or received.
64             push @tests, {
65                 name => "client-auth-${protocol_name}-request",
66                 server => {
67                     "MinProtocol" => $protocol,
68                     "MaxProtocol" => $protocol,
69                     "VerifyMode" => "Request"
70                 },
71                 client => {
72                     "MinProtocol" => $protocol,
73                     "MaxProtocol" => $protocol
74                 },
75                 test   => {
76                     "ExpectedResult" => "Success",
77                     "Method" => $method,
78                 },
79             };
80
81             # Handshake with client cert required but not present.
82             push @tests, {
83                 name => "client-auth-${protocol_name}-require-fail",
84                 server => {
85                     "MinProtocol" => $protocol,
86                     "MaxProtocol" => $protocol,
87                     "VerifyCAFile" => test_pem("root-cert.pem"),
88                     "VerifyMode" => "Require",
89                 },
90                 client => {
91                     "MinProtocol" => $protocol,
92                     "MaxProtocol" => $protocol
93                 },
94                 test   => {
95                     "ExpectedResult" => "ServerFail",
96                     "ExpectedServerAlert" => "HandshakeFailure",
97                     "Method" => $method,
98                 },
99             };
100
101             # Successful handshake with client authentication.
102             push @tests, {
103                 name => "client-auth-${protocol_name}-require",
104                 server => {
105                     "MinProtocol" => $protocol,
106                     "MaxProtocol" => $protocol,
107                     "ClientSignatureAlgorithms" => $clisigalgs,
108                     "VerifyCAFile" => test_pem("root-cert.pem"),
109                     "VerifyMode" => "Request",
110                 },
111                 client => {
112                     "MinProtocol" => $protocol,
113                     "MaxProtocol" => $protocol,
114                     "Certificate" => test_pem("ee-client-chain.pem"),
115                     "PrivateKey"  => test_pem("ee-key.pem"),
116                 },
117                 test   => {
118                     "ExpectedResult" => "Success",
119                     "ExpectedClientCertType" => "RSA",
120                     "ExpectedClientSignType" => $clisigtype,
121                     "ExpectedClientSignHash" => $clihash,
122                     "Method" => $method,
123                 },
124             };
125
126             # Handshake with client authentication but without the root certificate.
127             push @tests, {
128                 name => "client-auth-${protocol_name}-noroot",
129                 server => {
130                     "MinProtocol" => $protocol,
131                     "MaxProtocol" => $protocol,
132                     "VerifyMode" => "Require",
133                 },
134                 client => {
135                     "MinProtocol" => $protocol,
136                     "MaxProtocol" => $protocol,
137                     "Certificate" => test_pem("ee-client-chain.pem"),
138                     "PrivateKey"  => test_pem("ee-key.pem"),
139                 },
140                 test   => {
141                     "ExpectedResult" => "ServerFail",
142                     "ExpectedServerAlert" => $caalert,
143                     "Method" => $method,
144                 },
145             };
146         }
147     }
148 }
149
150 generate_tests();