2016-05-31 14:42:58 +00:00
|
|
|
# -*- 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";
|
2016-06-22 18:41:03 +00:00
|
|
|
my $caalert;
|
2016-05-31 14:42:58 +00:00
|
|
|
if (!$is_disabled[$_]) {
|
2016-06-22 18:41:03 +00:00
|
|
|
if ($protocol_name eq "SSLv3") {
|
|
|
|
$caalert = "BadCertificate";
|
|
|
|
} else {
|
|
|
|
$caalert = "UnknownCA";
|
|
|
|
}
|
2017-01-15 15:59:48 +00:00
|
|
|
my $clihash;
|
|
|
|
my $clisigalgs;
|
|
|
|
# TODO add TLSv1.3 versions
|
|
|
|
if ($protocol_name eq "TLSv1.2") {
|
|
|
|
$clihash = "SHA256";
|
|
|
|
$clisigalgs = "SHA256+RSA";
|
|
|
|
}
|
2016-05-31 14:42:58 +00:00
|
|
|
# Sanity-check simple handshake.
|
|
|
|
push @tests, {
|
|
|
|
name => "server-auth-${protocol_name}",
|
|
|
|
server => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
client => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
test => { "ExpectedResult" => "Success" },
|
|
|
|
};
|
|
|
|
|
|
|
|
# Handshake with client cert requested but not required or received.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-request",
|
|
|
|
server => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
|
|
|
"VerifyMode" => "Request"
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
client => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
test => { "ExpectedResult" => "Success" },
|
|
|
|
};
|
|
|
|
|
|
|
|
# Handshake with client cert required but not present.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-require-fail",
|
|
|
|
server => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
2016-05-31 14:42:58 +00:00
|
|
|
"VerifyCAFile" => "\${ENV::TEST_CERTS_DIR}${dir_sep}root-cert.pem",
|
|
|
|
"VerifyMode" => "Require",
|
|
|
|
},
|
|
|
|
client => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "ServerFail",
|
2016-07-21 14:29:48 +00:00
|
|
|
"ExpectedServerAlert" => "HandshakeFailure",
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
# Successful handshake with client authentication.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-require",
|
|
|
|
server => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
2017-01-15 15:59:48 +00:00
|
|
|
"ClientSignatureAlgorithms" => $clisigalgs,
|
2016-05-31 14:42:58 +00:00
|
|
|
"VerifyCAFile" => "\${ENV::TEST_CERTS_DIR}${dir_sep}root-cert.pem",
|
|
|
|
"VerifyMode" => "Request",
|
|
|
|
},
|
|
|
|
client => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
2016-05-31 14:42:58 +00:00
|
|
|
"Certificate" => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-client-chain.pem",
|
|
|
|
"PrivateKey" => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-key.pem",
|
|
|
|
},
|
2017-01-13 17:41:48 +00:00
|
|
|
test => { "ExpectedResult" => "Success",
|
|
|
|
"ExpectedClientCertType" => "RSA",
|
2017-01-15 15:59:48 +00:00
|
|
|
"ExpectedClientSignHash" => $clihash,
|
2017-01-13 17:41:48 +00:00
|
|
|
},
|
2016-05-31 14:42:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Handshake with client authentication but without the root certificate.
|
|
|
|
push @tests, {
|
|
|
|
name => "client-auth-${protocol_name}-noroot",
|
|
|
|
server => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
2016-05-31 14:42:58 +00:00
|
|
|
"VerifyMode" => "Require",
|
|
|
|
},
|
|
|
|
client => {
|
2016-06-22 15:34:26 +00:00
|
|
|
"MinProtocol" => $protocol,
|
|
|
|
"MaxProtocol" => $protocol,
|
2016-05-31 14:42:58 +00:00
|
|
|
"Certificate" => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-client-chain.pem",
|
|
|
|
"PrivateKey" => "\${ENV::TEST_CERTS_DIR}${dir_sep}ee-key.pem",
|
|
|
|
},
|
|
|
|
test => {
|
|
|
|
"ExpectedResult" => "ServerFail",
|
2016-07-21 14:29:48 +00:00
|
|
|
"ExpectedServerAlert" => $caalert,
|
2016-05-31 14:42:58 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_tests();
|