]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/70-test_tls13alerts.t
threads_pthread.c: change inline to ossl_inline
[thirdparty/openssl.git] / test / recipes / 70-test_tls13alerts.t
CommitLineData
f460e839 1#! /usr/bin/env perl
a28d06f3 2# Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved.
f460e839 3#
909f1a2e 4# Licensed under the Apache License 2.0 (the "License"). You may not use
f460e839
MC
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
9use strict;
10use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
11use OpenSSL::Test::Utils;
12use TLSProxy::Proxy;
13
14my $test_name = "test_tls13alerts";
15setup($test_name);
16
17plan skip_all => "TLSProxy isn't usable on $^O"
18 if $^O =~ /^(VMS)$/;
19
20plan skip_all => "$test_name needs the dynamic engine feature enabled"
21 if disabled("engine") || disabled("dynamic-engine");
22
23plan skip_all => "$test_name needs the sock feature enabled"
24 if disabled("sock");
25
26plan skip_all => "$test_name needs TLS1.3 enabled"
a763ca11 27 if disabled("tls1_3") || (disabled("ec") && disabled("dh"));
f460e839 28
f460e839
MC
29my $proxy = TLSProxy::Proxy->new(
30 undef,
31 cmdstr(app(["openssl"]), display => 1),
32 srctop_file("apps", "server.pem"),
33 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
34);
35
36#Test 1: We test that a server can handle an unencrypted alert when normally the
37# next message is encrypted
38$proxy->filter(\&alert_filter);
39$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
40plan tests => 1;
41my $alert = TLSProxy::Message->alert();
164a541b 42ok(TLSProxy::Message->fail() && !$alert->server() && !$alert->encrypted(), "Client sends an unencrypted alert");
f460e839
MC
43
44sub alert_filter
45{
46 my $proxy = shift;
47
48 if ($proxy->flight != 1) {
49 return;
50 }
51
52 ${$proxy->message_list}[1]->session_id_len(1);
53 ${$proxy->message_list}[1]->repack();
54}