Add chain to PKCS#12 test file generation in 90-test_store.t
[openssl.git] / test / recipes / 90-test_store.t
index d453512667f1ae4be2920c2d6223c32fb5f212e8..0905232e35cf5021d3b56683b76965e13a4d23ed 100644 (file)
@@ -1,7 +1,7 @@
 #! /usr/bin/env perl
-# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
+# Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
 #
-# Licensed under the OpenSSL license (the "License").  You may not use
+# Licensed under the Apache License 2.0 (the "License").  You may not use
 # this file except in compliance with the License.  You can obtain a copy
 # in the file LICENSE in the source distribution or at
 # https://www.openssl.org/source/license.html
@@ -15,6 +15,9 @@ use OpenSSL::Test::Utils;
 my $test_name = "test_store";
 setup($test_name);
 
+my $mingw = config('target') =~ m|^mingw|;
+my $cnf = srctop_file("test", "ca-and-certs.cnf");
+
 my @noexist_files =
     ( "test/blahdiblah.pem",
       "test/blahdibleh.der" );
@@ -104,8 +107,9 @@ indir "store_$$" => sub {
 
             ok(run(app(["openssl", "storeutl", "-noout", $file])));
             ok(run(app(["openssl", "storeutl", "-noout", to_abs_file($file)])));
+        SKIP:
             {
-                local $ENV{MSYS2_ARG_CONV_EXCL} = "file:";
+                skip "file: tests disabled on MingW", 4 if $mingw;
 
                 ok(run(app(["openssl", "storeutl", "-noout",
                             to_abs_file_uri($file)])));
@@ -123,8 +127,9 @@ indir "store_$$" => sub {
             ok(run(app(["openssl", "storeutl",  "-noout", "-passin",
                         "pass:password", to_abs_file($_)])));
 
+        SKIP:
             {
-                local $ENV{MSYS2_ARG_CONV_EXCL} = "file:";
+                skip "file: tests disabled on MingW", 2 if $mingw;
 
                 ok(run(app(["openssl", "storeutl", "-noout", "-passin",
                             "pass:password", to_abs_file_uri($_)])));
@@ -133,14 +138,20 @@ indir "store_$$" => sub {
             }
         }
         foreach (values %generated_file_files) {
-            local $ENV{MSYS2_ARG_CONV_EXCL} = "file:";
+        SKIP:
+            {
+                skip "file: tests disabled on MingW", 1 if $mingw;
 
-            ok(run(app(["openssl", "storeutl",  "-noout", $_])));
+                ok(run(app(["openssl", "storeutl",  "-noout", $_])));
+            }
         }
         foreach (@noexist_file_files) {
-            local $ENV{MSYS2_ARG_CONV_EXCL} = "file:";
+        SKIP:
+            {
+                skip "file: tests disabled on MingW", 1 if $mingw;
 
-            ok(!run(app(["openssl", "storeutl",  "-noout", $_])));
+                ok(!run(app(["openssl", "storeutl",  "-noout", $_])));
+            }
         }
         {
             my $dir = srctop_dir("test", "certs");
@@ -148,8 +159,9 @@ indir "store_$$" => sub {
             ok(run(app(["openssl", "storeutl",  "-noout", $dir])));
             ok(run(app(["openssl", "storeutl",  "-noout",
                         to_abs_file($dir, 1)])));
+        SKIP:
             {
-                local $ENV{MSYS2_ARG_CONV_EXCL} = "file:";
+                skip "file: tests disabled on MingW", 1 if $mingw;
 
                 ok(run(app(["openssl", "storeutl",  "-noout",
                             to_abs_file_uri($dir, 1)])));
@@ -284,7 +296,7 @@ sub init {
                       }, grep(/-key-pkcs8-pbes2-sha256\.pem$/, @generated_files))
             # *-cert.pem (intermediary for the .p12 inits)
             && run(app(["openssl", "req", "-x509",
-                        "-config", data_file("ca.cnf"), "-nodes",
+                        "-config", $cnf, "-nodes",
                         "-out", "cacert.pem", "-keyout", "cakey.pem"]))
             && runall(sub {
                           my $srckey = shift;
@@ -292,7 +304,7 @@ sub init {
                           (my $csr = $dstfile) =~ s|\.pem|.csr|;
 
                           (run(app(["openssl", "req", "-new",
-                                    "-config", data_file("user.cnf"),
+                                    "-config", $cnf,
                                     "-key", $srckey, "-out", $csr]))
                            &&
                            run(app(["openssl", "x509", "-days", "3650",
@@ -349,6 +361,7 @@ sub init {
                           }
                           run(app(["openssl", "pkcs12", "-inkey", $srckey,
                                    "-in", $srccert, "-passout", "pass:password",
+                                   "-chain", "-CAfile", "cacert.pem",
                                    "-export", "-macalg", $macalg,
                                    "-certpbe", $certpbe, "-keypbe", $keypbe,
                                    "-out", $dstfile]));