]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/80-test_ca.t
-precert doesn't work when configured no-ct, don't try to test it then
[thirdparty/openssl.git] / test / recipes / 80-test_ca.t
CommitLineData
596d6b7e
RS
1#! /usr/bin/env perl
2# Copyright 2015-2016 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
88b8a527
RL
9
10use strict;
11use warnings;
12
13use POSIX;
e9fd82f6 14use File::Path 2.00 qw/rmtree/;
42e0ccdf 15use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file/;
51f5930a 16use OpenSSL::Test::Utils;
88b8a527
RL
17
18setup("test_ca");
19
25c78440 20$ENV{OPENSSL} = cmdstr(app(["openssl"]), display => 1);
42e0ccdf
RL
21my $std_openssl_cnf =
22 srctop_file("apps", $^O eq "VMS" ? "openssl-vms.cnf" : "openssl.cnf");
88b8a527 23
e9fd82f6 24rmtree("demoCA", { safe => 0 });
88b8a527 25
caee75d2 26plan tests => 5;
88b8a527 27 SKIP: {
ac1a998d 28 $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "CAss.cnf").'"';
a4c5f859 29 skip "failed creating CA structure", 4
7d9b2d53 30 if !ok(run(perlapp(["CA.pl","-newca"], stdin => undef)),
88b8a527
RL
31 'creating CA structure');
32
ac1a998d 33 $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "Uss.cnf").'"';
a4c5f859 34 skip "failed creating new certificate request", 3
7d9b2d53 35 if !ok(run(perlapp(["CA.pl","-newreq"])),
32804b04 36 'creating certificate request');
88b8a527 37
ac1a998d 38 $ENV{OPENSSL_CONFIG} = '-config "'.$std_openssl_cnf.'"';
a4c5f859 39 skip "failed to sign certificate request", 2
7d9b2d53 40 if !is(yes(cmdstr(perlapp(["CA.pl", "-sign"]))), 0,
88b8a527
RL
41 'signing certificate request');
42
7d9b2d53 43 ok(run(perlapp(["CA.pl", "-verify", "newcert.pem"])),
32804b04 44 'verifying new certificate');
caee75d2 45
51f5930a
RL
46 skip "CT not configured, can't use -precert", 1
47 if disabled("ct");
48
caee75d2 49 $ENV{OPENSSL_CONFIG} = "-config ".srctop_file("test", "Uss.cnf");
505fb999 50 ok(run(perlapp(["CA.pl", "-precert"], stderr => undef)),
caee75d2 51 'creating new pre-certificate');
88b8a527
RL
52}
53
54
e9fd82f6 55rmtree("demoCA", { safe => 0 });
c9d24373 56unlink "newcert.pem", "newreq.pem", "newkey.pem";
88b8a527
RL
57
58
59sub yes {
4034c38b 60 my $cntr = 10;
88b8a527
RL
61 open(PIPE, "|-", join(" ",@_));
62 local $SIG{PIPE} = "IGNORE";
4034c38b 63 1 while $cntr-- > 0 && print PIPE "y\n";
88b8a527
RL
64 close PIPE;
65 return 0;
66}
42e0ccdf 67