yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 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_sslcertstatus"; |
| 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 the ocsp feature enabled" |
| 27 | if disabled("ocsp"); |
| 28 | |
| 29 | plan skip_all => "$test_name needs TLS enabled" |
| 30 | if alldisabled(available_protocols("tls")) |
| 31 | || (!disabled("tls1_3") && disabled("tls1_2")); |
| 32 | |
| 33 | $ENV{OPENSSL_ia32cap} = '~0x200000200000000'; |
| 34 | my $proxy = TLSProxy::Proxy->new( |
| 35 | \&certstatus_filter, |
| 36 | cmdstr(app(["openssl"]), display => 1), |
| 37 | srctop_file("apps", "server.pem"), |
| 38 | (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE}) |
| 39 | ); |
| 40 | |
| 41 | #Test 1: Sending a status_request extension in both ClientHello and |
| 42 | #ServerHello but then omitting the CertificateStatus message is valid |
| 43 | $proxy->clientflags("-status -no_tls1_3"); |
| 44 | $proxy->start() or plan skip_all => "Unable to start up Proxy for tests"; |
| 45 | plan tests => 1; |
| 46 | ok(TLSProxy::Message->success, "Missing CertificateStatus message"); |
| 47 | |
| 48 | sub certstatus_filter |
| 49 | { |
| 50 | my $proxy = shift; |
| 51 | |
| 52 | # We're only interested in the initial ServerHello |
| 53 | if ($proxy->flight != 1) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | foreach my $message (@{$proxy->message_list}) { |
| 58 | if ($message->mt == TLSProxy::Message::MT_SERVER_HELLO) { |
| 59 | #Add the status_request to the ServerHello even though we are not |
| 60 | #going to send a CertificateStatus message |
| 61 | $message->set_extension(TLSProxy::Message::EXT_STATUS_REQUEST, |
| 62 | ""); |
| 63 | |
| 64 | $message->repack(); |
| 65 | } |
| 66 | } |
| 67 | } |