]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/70-test_sslvertol.t
2 # Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
10 use OpenSSL
::Test qw
/:DEFAULT cmdstr srctop_file bldtop_dir/;
11 use OpenSSL
::Test
::Utils
;
14 my $test_name = "test_sslextension";
17 plan skip_all
=> "TLSProxy isn't usable on $^O"
18 if $^O
=~ /^(VMS|MSWin32)$/;
20 plan skip_all
=> "$test_name needs the dynamic engine feature enabled"
21 if disabled
("engine") || disabled
("dynamic-engine");
23 plan skip_all
=> "$test_name needs the sock feature enabled"
26 plan skip_all
=> "$test_name needs TLS enabled"
27 if alldisabled
(available_protocols
("tls"));
29 $ENV{OPENSSL_ia32cap
} = '~0x200000200000000';
30 my $proxy = TLSProxy
::Proxy
->new(
31 \
&vers_tolerance_filter
,
32 cmdstr
(app
(["openssl"]), display
=> 1),
33 srctop_file
("apps", "server.pem"),
34 (!$ENV{HARNESS_ACTIVE
} || $ENV{HARNESS_VERBOSE
})
37 #This file does tests without the supported_versions extension.
38 #See 70-test_sslversions.t for tests with supported versions.
39 #Test 1: Asking for TLS1.4 should pass and negotiate TLS1.2
40 my $client_version = TLSProxy
::Record
::VERS_TLS_1_4
;
41 $proxy->clientflags("-no_tls1_3");
42 $proxy->start() or plan skip_all
=> "Unable to start up Proxy for tests";
44 my $record = pop @
{$proxy->record_list};
45 ok
(TLSProxy
::Message
->success()
46 && $record->version() == TLSProxy
::Record
::VERS_TLS_1_2
,
47 "Version tolerance test, TLS 1.4");
49 #Test 2: Asking for TLS1.3 should succeed and negotiate TLS1.2
51 $proxy->clientflags("-no_tls1_3");
53 $record = pop @
{$proxy->record_list};
54 ok
(TLSProxy
::Message
->success()
55 && $record->version() == TLSProxy
::Record
::VERS_TLS_1_2
,
56 "Version tolerance test, TLS 1.3");
58 #Test 3: Testing something below SSLv3 should fail
59 $client_version = TLSProxy
::Record
::VERS_SSL_3_0
- 1;
61 $proxy->clientflags("-no_tls1_3");
63 ok
(TLSProxy
::Message
->fail(), "Version tolerance test, SSL < 3.0");
65 sub vers_tolerance_filter
69 # We're only interested in the initial ClientHello
70 if ($proxy->flight != 0) {
74 foreach my $message (@
{$proxy->message_list}) {
75 if ($message->mt == TLSProxy
::Message
::MT_CLIENT_HELLO
) {
76 #Set the client version
77 #Anything above the max supported version (TLS1.2) should succeed
78 #Anything below SSLv3 should fail
79 $message->client_version($client_version);