]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/80-test_ca.t
Replace "SSLeay" in API with OpenSSL
[thirdparty/openssl.git] / test / recipes / 80-test_ca.t
CommitLineData
88b8a527
RL
1#! /usr/bin/perl
2
3use strict;
4use warnings;
5
6use POSIX;
7use File::Spec::Functions qw/splitdir curdir catfile devnull/;
fb921436 8use File::Path 2.00 qw/remove_tree/;
88b8a527
RL
9use OpenSSL::Test qw/:DEFAULT cmdstr top_file quotify/;
10
11setup("test_ca");
12
13my $perl = $^X;
14$ENV{OPENSSL} = cmdstr(app(["openssl"]));
15my $CA_pl = top_file("apps", "CA.pl");
16my $std_openssl_cnf = top_file("apps", "openssl.cnf");
17
18($perl) = quotify($perl) unless $^O eq "VMS"; # never quotify a command on VMS. Ever!
19
20remove_tree("demoCA", { safe => 0 });
21
22plan tests => 4;
23 SKIP: {
b0700d2c 24 $ENV{OPENSSL_CONFIG} = "-config ".top_file("test", "CAss.cnf");
88b8a527
RL
25 skip "failed creating CA structure", 3
26 if !is(system("$perl ".$CA_pl." -newca < ".devnull()." 2>&1"), 0,
27 'creating CA structure');
28
b0700d2c 29 $ENV{OPENSSL_CONFIG} = "-config ".top_file("test", "Uss.cnf");
88b8a527
RL
30 skip "failed creating new certificate request", 2
31 if !is(system("$perl ".$CA_pl." -newreq 2>&1"), 0,
32 'creating new certificate request');
33
b0700d2c 34 $ENV{OPENSSL_CONFIG} = "-config ".$std_openssl_cnf;
88b8a527
RL
35 skip "failed to sign certificate request", 1
36 if !is(yes("$perl ".$CA_pl." -sign 2>&1"), 0,
37 'signing certificate request');
38
39 is(system("$perl ".$CA_pl." -verify newcert.pem 2>&1"), 0,
40 'verifying new certificate');
41}
42
43
44remove_tree("demoCA", { safe => 0 });
45unlink "newcert.pem", "newreq.pem";
46
47
48sub yes {
49 open(PIPE, "|-", join(" ",@_));
50 local $SIG{PIPE} = "IGNORE";
51 1 while print PIPE "y\n";
52 close PIPE;
53 return 0;
54}