Custome built dladdr() for AIX.
[openssl.git] / test / recipes / 70-test_sslvertol.t
1 #! /usr/bin/env perl
2 # Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
3 #
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
8
9 use strict;
10 use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
11 use OpenSSL::Test::Utils;
12 use TLSProxy::Proxy;
13
14 my $test_name = "test_sslextension";
15 setup($test_name);
16
17 plan skip_all => "TLSProxy isn't usable on $^O"
18     if $^O =~ /^(VMS)$/;
19
20 plan skip_all => "$test_name needs the dynamic engine feature enabled"
21     if disabled("engine") || disabled("dynamic-engine");
22
23 plan skip_all => "$test_name needs the sock feature enabled"
24     if disabled("sock");
25
26 plan skip_all => "$test_name needs TLS enabled"
27     if alldisabled(available_protocols("tls"));
28
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})
35 );
36
37 #Test 1: Asking for TLS1.3 should pass
38 my $client_version = TLSProxy::Record::VERS_TLS_1_3;
39 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
40 plan tests => 2;
41 ok(TLSProxy::Message->success(), "Version tolerance test, TLS 1.3");
42
43 #Test 2: Testing something below SSLv3 should fail
44 $client_version = TLSProxy::Record::VERS_SSL_3_0 - 1;
45 $proxy->clear();
46 $proxy->start();
47 ok(TLSProxy::Message->fail(), "Version tolerance test, SSL < 3.0");
48
49 sub vers_tolerance_filter
50 {
51     my $proxy = shift;
52
53     # We're only interested in the initial ClientHello
54     if ($proxy->flight != 0) {
55         return;
56     }
57
58     foreach my $message (@{$proxy->message_list}) {
59         if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
60             #Set the client version
61             #Anything above the max supported version (TLS1.2) should succeed
62             #Anything below SSLv3 should fail
63             $message->client_version($client_version);
64             $message->repack();
65         }
66     }
67 }