2 # Copyright 2017 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 srctop_dir bldtop_dir/;
11 use OpenSSL::Test::Utils;
12 use File::Temp qw(tempfile);
15 my $test_name = "test_tls13psk";
18 plan skip_all => "TLSProxy isn't usable on $^O"
19 if $^O =~ /^(VMS|MSWin32)$/;
21 plan skip_all => "$test_name needs the dynamic engine feature enabled"
22 if disabled("engine") || disabled("dynamic-engine");
24 plan skip_all => "$test_name needs the sock feature enabled"
27 plan skip_all => "$test_name needs TLSv1.3 enabled"
28 if disabled("tls1_3");
30 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
31 $ENV{CTLOG_FILE} = srctop_file("test", "ct", "log_list.conf");
33 my $proxy = TLSProxy::Proxy->new(
35 cmdstr(app(["openssl"]), display => 1),
36 srctop_file("apps", "server.pem"),
37 (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
40 #Most PSK tests are done in test_ssl_new. This just checks sending a PSK
41 #extension when it isn't in the last place in a ClientHello
43 #Test 1: First get a session
44 (undef, my $session) = tempfile();
45 $proxy->clientflags("-sess_out ".$session);
46 $proxy->sessionfile($session);
47 $proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
49 ok(TLSProxy::Message->success(), "Initial connection");
51 #Test 2: Attempt a resume with PSK not in last place. Should fail
53 $proxy->clientflags("-sess_in ".$session);
54 $proxy->filter(\&modify_psk_filter);
56 ok(TLSProxy::Message->fail(), "PSK not last");
64 # We're only interested in the initial ClientHello
65 return if ($proxy->flight != 0);
67 foreach my $message (@{$proxy->message_list}) {
68 if ($message->mt == TLSProxy::Message::MT_CLIENT_HELLO) {
69 $message->set_extension(TLSProxy::Message::EXT_FORCE_LAST, "");