2 # Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (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
14 use File::Path 2.00 qw/rmtree/;
15 use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file/;
16 use OpenSSL::Test::Utils;
20 $ENV{OPENSSL} = cmdstr(app(["openssl"]), display => 1);
22 srctop_file("apps", $^O eq "VMS" ? "openssl-vms.cnf" : "openssl.cnf");
24 rmtree("demoCA", { safe => 0 });
28 $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "CAss.cnf").'"';
29 skip "failed creating CA structure", 4
30 if !ok(run(perlapp(["CA.pl","-newca"], stdin => undef)),
31 'creating CA structure');
33 $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "Uss.cnf").'"';
34 skip "failed creating new certificate request", 3
35 if !ok(run(perlapp(["CA.pl","-newreq",
36 "-extra-req","-outform DER"])),
37 'creating certificate request');
38 $ENV{OPENSSL_CONFIG} = '-rand_serial -inform DER -config "'.$std_openssl_cnf.'"';
39 skip "failed to sign certificate request", 2
40 if !is(yes(cmdstr(perlapp(["CA.pl", "-sign", "-extra-ca"]))), 0,
41 'signing certificate request');
43 ok(run(perlapp(["CA.pl", "-verify", "newcert.pem"])),
44 'verifying new certificate');
46 skip "CT not configured, can't use -precert", 1
49 $ENV{OPENSSL_CONFIG} = '-config "'.srctop_file("test", "Uss.cnf").'"';
50 ok(run(perlapp(["CA.pl", "-precert"], stderr => undef)),
51 'creating new pre-certificate');
55 skip "SM2 is not supported by this OpenSSL build", 1
58 is(yes(cmdstr(app(["openssl", "ca", "-config",
59 srctop_file("test", "CAss.cnf"),
60 "-in", srctop_file("test", "certs", "sm2-csr.pem"),
61 "-out", "sm2-test.crt",
62 "-sigopt", "distid:1234567812345678",
63 "-vfyopt", "distid:1234567812345678",
65 "-cert", srctop_file("test", "certs", "sm2-root.crt"),
66 "-keyfile", srctop_file("test", "certs", "sm2-root.key")]))),
68 "Signing SM2 certificate request");
73 open(PIPE, "|-", join(" ",@_));
74 local $SIG{PIPE} = "IGNORE";
75 1 while $cntr-- > 0 && print PIPE "y\n";