04-client_auth.conf.in 4.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# -*- mode: perl; -*-

## SSL test configurations

package ssltests;

use strict;
use warnings;

use OpenSSL::Test;
use OpenSSL::Test::Utils qw(anydisabled);
setup("no_test_here");

# We test version-flexible negotiation (undef) and each protocol version.
my @protocols = (undef, "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2");

my @is_disabled = (0);
push @is_disabled, anydisabled("ssl3", "tls1", "tls1_1", "tls1_2");

our @tests = ();

my $dir_sep = $^O ne "VMS" ? "/" : "";

sub generate_tests() {

    foreach (0..$#protocols) {
        my $protocol = $protocols[$_];
        my $protocol_name = $protocol || "flex";
29
        my $caalert;
30
        if (!$is_disabled[$_]) {
31 32 33 34 35
            if ($protocol_name eq "SSLv3") {
                $caalert = "BadCertificate";
            } else {
                $caalert = "UnknownCA";
            }
D
Dr. Stephen Henson 已提交
36 37 38 39 40 41 42
            my $clihash;
            my $clisigalgs;
            # TODO add TLSv1.3 versions
            if ($protocol_name eq "TLSv1.2") {
                $clihash = "SHA256";
                $clisigalgs = "SHA256+RSA";
            }
43 44 45 46
            # Sanity-check simple handshake.
            push @tests, {
                name => "server-auth-${protocol_name}",
                server => {
M
Matt Caswell 已提交
47 48
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol
49 50
                },
                client => {
M
Matt Caswell 已提交
51 52
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol
53 54 55 56 57 58 59 60
                },
                test   => { "ExpectedResult" => "Success" },
            };

            # Handshake with client cert requested but not required or received.
            push @tests, {
                name => "client-auth-${protocol_name}-request",
                server => {
M
Matt Caswell 已提交
61 62 63
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol,
                    "VerifyMode" => "Request"
64 65
                },
                client => {
M
Matt Caswell 已提交
66 67
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol
68 69 70 71 72 73 74 75
                },
                test   => { "ExpectedResult" => "Success" },
            };

            # Handshake with client cert required but not present.
            push @tests, {
                name => "client-auth-${protocol_name}-require-fail",
                server => {
M
Matt Caswell 已提交
76 77
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol,
78 79 80 81
                    "VerifyCAFile" => "\${ENV::TEST_CERTS_DIR}${dir_sep}root-cert.pem",
                    "VerifyMode" => "Require",
                },
                client => {
M
Matt Caswell 已提交
82 83
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol
84 85 86
                },
                test   => {
                    "ExpectedResult" => "ServerFail",
E
Emilia Kasper 已提交
87
                    "ExpectedServerAlert" => "HandshakeFailure",
88 89 90 91 92 93 94
                },
            };

            # Successful handshake with client authentication.
            push @tests, {
                name => "client-auth-${protocol_name}-require",
                server => {
M
Matt Caswell 已提交
95 96
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol,
D
Dr. Stephen Henson 已提交
97
                    "ClientSignatureAlgorithms" => $clisigalgs,
98 99 100 101
                    "VerifyCAFile" => "\${ENV::TEST_CERTS_DIR}${dir_sep}root-cert.pem",
                    "VerifyMode" => "Request",
                },
                client => {
M
Matt Caswell 已提交
102 103
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol,
104 105 106
                    "Certificate" => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-client-chain.pem",
                    "PrivateKey"  => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-key.pem",
                },
D
Dr. Stephen Henson 已提交
107 108
                test   => { "ExpectedResult" => "Success",
                            "ExpectedClientCertType" => "RSA",
D
Dr. Stephen Henson 已提交
109
                            "ExpectedClientSignHash" => $clihash,
D
Dr. Stephen Henson 已提交
110
                },
111 112 113 114 115 116
            };

            # Handshake with client authentication but without the root certificate.
            push @tests, {
                name => "client-auth-${protocol_name}-noroot",
                server => {
M
Matt Caswell 已提交
117 118
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol,
119 120 121
                    "VerifyMode" => "Require",
                },
                client => {
M
Matt Caswell 已提交
122 123
                    "MinProtocol" => $protocol,
                    "MaxProtocol" => $protocol,
124 125 126 127 128
                    "Certificate" => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-client-chain.pem",
                    "PrivateKey"  => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-key.pem",
                },
                test   => {
                    "ExpectedResult" => "ServerFail",
E
Emilia Kasper 已提交
129
                    "ExpectedServerAlert" => $caalert,
130 131 132 133 134 135 136
                },
            };
        }
    }
}
 
generate_tests();