xref: /freebsd/crypto/openssl/test/recipes/70-test_sslcertstatus.t (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#! /usr/bin/env perl
2*e0c4386eSCy Schubert# Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert
9*e0c4386eSCy Schubertuse strict;
10*e0c4386eSCy Schubertuse OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
11*e0c4386eSCy Schubertuse OpenSSL::Test::Utils;
12*e0c4386eSCy Schubertuse TLSProxy::Proxy;
13*e0c4386eSCy Schubert
14*e0c4386eSCy Schubertmy $test_name = "test_sslcertstatus";
15*e0c4386eSCy Schubertsetup($test_name);
16*e0c4386eSCy Schubert
17*e0c4386eSCy Schubertplan skip_all => "TLSProxy isn't usable on $^O"
18*e0c4386eSCy Schubert    if $^O =~ /^(VMS)$/;
19*e0c4386eSCy Schubert
20*e0c4386eSCy Schubertplan skip_all => "$test_name needs the dynamic engine feature enabled"
21*e0c4386eSCy Schubert    if disabled("engine") || disabled("dynamic-engine");
22*e0c4386eSCy Schubert
23*e0c4386eSCy Schubertplan skip_all => "$test_name needs the sock feature enabled"
24*e0c4386eSCy Schubert    if disabled("sock");
25*e0c4386eSCy Schubert
26*e0c4386eSCy Schubertplan skip_all => "$test_name needs the ocsp feature enabled"
27*e0c4386eSCy Schubert    if disabled("ocsp");
28*e0c4386eSCy Schubert
29*e0c4386eSCy Schubertplan skip_all => "$test_name needs TLS enabled"
30*e0c4386eSCy Schubert    if alldisabled(available_protocols("tls"))
31*e0c4386eSCy Schubert       || (!disabled("tls1_3") && disabled("tls1_2"));
32*e0c4386eSCy Schubert
33*e0c4386eSCy Schubert$ENV{OPENSSL_ia32cap} = '~0x200000200000000';
34*e0c4386eSCy Schubertmy $proxy = TLSProxy::Proxy->new(
35*e0c4386eSCy Schubert    \&certstatus_filter,
36*e0c4386eSCy Schubert    cmdstr(app(["openssl"]), display => 1),
37*e0c4386eSCy Schubert    srctop_file("apps", "server.pem"),
38*e0c4386eSCy Schubert    (!$ENV{HARNESS_ACTIVE} || $ENV{HARNESS_VERBOSE})
39*e0c4386eSCy Schubert);
40*e0c4386eSCy Schubert
41*e0c4386eSCy Schubert#Test 1: Sending a status_request extension in both ClientHello and
42*e0c4386eSCy Schubert#ServerHello but then omitting the CertificateStatus message is valid
43*e0c4386eSCy Schubert$proxy->clientflags("-status -no_tls1_3");
44*e0c4386eSCy Schubert$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
45*e0c4386eSCy Schubertplan tests => 1;
46*e0c4386eSCy Schubertok(TLSProxy::Message->success, "Missing CertificateStatus message");
47*e0c4386eSCy Schubert
48*e0c4386eSCy Schubertsub certstatus_filter
49*e0c4386eSCy Schubert{
50*e0c4386eSCy Schubert    my $proxy = shift;
51*e0c4386eSCy Schubert
52*e0c4386eSCy Schubert    # We're only interested in the initial ServerHello
53*e0c4386eSCy Schubert    if ($proxy->flight != 1) {
54*e0c4386eSCy Schubert        return;
55*e0c4386eSCy Schubert    }
56*e0c4386eSCy Schubert
57*e0c4386eSCy Schubert    foreach my $message (@{$proxy->message_list}) {
58*e0c4386eSCy Schubert        if ($message->mt == TLSProxy::Message::MT_SERVER_HELLO) {
59*e0c4386eSCy Schubert            #Add the status_request to the ServerHello even though we are not
60*e0c4386eSCy Schubert            #going to send a CertificateStatus message
61*e0c4386eSCy Schubert            $message->set_extension(TLSProxy::Message::EXT_STATUS_REQUEST,
62*e0c4386eSCy Schubert                                    "");
63*e0c4386eSCy Schubert
64*e0c4386eSCy Schubert            $message->repack();
65*e0c4386eSCy Schubert        }
66*e0c4386eSCy Schubert    }
67*e0c4386eSCy Schubert}
68