70-test_sslcertstatus.t 2.3 KB
Newer Older
R
Rich Salz 已提交
1 2
#! /usr/bin/env perl
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
3
#
R
Rich Salz 已提交
4 5 6 7
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# 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 13 14 15 16
use TLSProxy::Proxy;

my $test_name = "test_sslcertstatus";
setup($test_name);

17
plan skip_all => "TLSProxy isn't usable on $^O"
18
    if $^O =~ /^(VMS|MSWin32)$/;
19

20
plan skip_all => "$test_name needs the dynamic engine feature enabled"
21
    if disabled("engine") || disabled("dynamic-engine");
22

M
Matt Caswell 已提交
23 24 25
plan skip_all => "$test_name needs the sock feature enabled"
    if disabled("sock");

M
Matt Caswell 已提交
26 27 28
plan skip_all => "$test_name needs the ocsp feature enabled"
    if disabled("ocsp");

M
Matt Caswell 已提交
29 30 31
plan skip_all => "$test_name needs TLS enabled"
    if alldisabled(available_protocols("tls"));

32 33 34
$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
my $proxy = TLSProxy::Proxy->new(
    \&certstatus_filter,
35
    cmdstr(app(["openssl"]), display => 1),
36 37
    srctop_file("apps", "server.pem"),
    (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
38 39
);

40 41
#Test 1: Sending a status_request extension in both ClientHello and
#ServerHello but then omitting the CertificateStatus message is valid
M
Matt Caswell 已提交
42 43 44
#TODO(TLS1.3): Temporarily disabling this test in TLS1.3 until we've completed
#the move the status request extension to the Certificate message.
$proxy->clientflags("-status -no_tls1_3");
45 46
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
plan tests => 1;
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
ok(TLSProxy::Message->success, "Missing CertificateStatus message");

sub certstatus_filter
{
    my $proxy = shift;

    # We're only interested in the initial ServerHello
    if ($proxy->flight != 1) {
        return;
    }

    foreach my $message (@{$proxy->message_list}) {
        if ($message->mt == TLSProxy::Message::MT_SERVER_HELLO) {
            #Add the status_request to the ServerHello even though we are not
            #going to send a CertificateStatus message
E
Emilia Kasper 已提交
62
            $message->set_extension(TLSProxy::Message::EXT_STATUS_REQUEST,
63 64 65 66 67 68
                                    "");

            $message->repack();
        }
    }
}