]>
Commit | Line | Data |
---|---|---|
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 | |
10 | use strict; | |
11 | use warnings; | |
12 | ||
13 | use POSIX; | |
e9fd82f6 | 14 | use File::Path 2.00 qw/rmtree/; |
42e0ccdf | 15 | use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file/; |
88b8a527 RL |
16 | |
17 | setup("test_ca"); | |
18 | ||
25c78440 | 19 | $ENV{OPENSSL} = cmdstr(app(["openssl"]), display => 1); |
42e0ccdf RL |
20 | my $std_openssl_cnf = |
21 | srctop_file("apps", $^O eq "VMS" ? "openssl-vms.cnf" : "openssl.cnf"); | |
88b8a527 | 22 | |
e9fd82f6 | 23 | rmtree("demoCA", { safe => 0 }); |
88b8a527 | 24 | |
caee75d2 | 25 | plan tests => 5; |
88b8a527 | 26 | SKIP: { |
ac1a998d | 27 | $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "CAss.cnf").'"'; |
88b8a527 | 28 | skip "failed creating CA structure", 3 |
7d9b2d53 | 29 | if !ok(run(perlapp(["CA.pl","-newca"], stdin => undef)), |
88b8a527 RL |
30 | 'creating CA structure'); |
31 | ||
ac1a998d | 32 | $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "Uss.cnf").'"'; |
88b8a527 | 33 | skip "failed creating new certificate request", 2 |
7d9b2d53 | 34 | if !ok(run(perlapp(["CA.pl","-newreq"])), |
32804b04 | 35 | 'creating certificate request'); |
88b8a527 | 36 | |
ac1a998d | 37 | $ENV{OPENSSL_CONFIG} = '-config "'.$std_openssl_cnf.'"'; |
88b8a527 | 38 | skip "failed to sign certificate request", 1 |
7d9b2d53 | 39 | if !is(yes(cmdstr(perlapp(["CA.pl", "-sign"]))), 0, |
88b8a527 RL |
40 | 'signing certificate request'); |
41 | ||
7d9b2d53 | 42 | ok(run(perlapp(["CA.pl", "-verify", "newcert.pem"])), |
32804b04 | 43 | 'verifying new certificate'); |
caee75d2 RP |
44 | |
45 | $ENV{OPENSSL_CONFIG} = "-config ".srctop_file("test", "Uss.cnf"); | |
46 | ok(run(perlapp(["CA.pl", "-newprecert"], stderr => undef)), | |
47 | 'creating new pre-certificate'); | |
88b8a527 RL |
48 | } |
49 | ||
50 | ||
e9fd82f6 | 51 | rmtree("demoCA", { safe => 0 }); |
c9d24373 | 52 | unlink "newcert.pem", "newreq.pem", "newkey.pem"; |
88b8a527 RL |
53 | |
54 | ||
55 | sub yes { | |
4034c38b | 56 | my $cntr = 10; |
88b8a527 RL |
57 | open(PIPE, "|-", join(" ",@_)); |
58 | local $SIG{PIPE} = "IGNORE"; | |
4034c38b | 59 | 1 while $cntr-- > 0 && print PIPE "y\n"; |
88b8a527 RL |
60 | close PIPE; |
61 | return 0; | |
62 | } | |
42e0ccdf | 63 |