1 #! /usr/bin/env perl 2 # Copyright 2023 The OpenSSL Project Authors. All Rights Reserved. 3 # 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 8 9 # This collects specific use cases, and tests our handling 10 11 use File::Spec::Functions; 12 use File::Copy; 13 use MIME::Base64; 14 use OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file bldtop_dir 15 data_file); 16 use OpenSSL::Test::Utils; 17 18 my $test_name = "test_store_cases"; 19 setup($test_name); 20 21 plan tests => 2; 22 23 my $stderr; 24 25 # The case of the garbage PKCS#12 DER file where a passphrase was 26 # prompted for. That should not have happened. 27 $stderr = 'garbage-pkcs12.stderr.txt'; 28 ok(!run(app(['openssl', 'storeutl', '-passin', 'pass:invalidapass', 29 data_file('garbage-pkcs12.p12')], 30 stderr => $stderr)), 31 "checking that storeutl fails when given a garbage pkcs12 file"); 32 open DATA, $stderr; 33 @match = grep /try_pkcs12:.*?:maybe wrong password$/, <DATA>; 34 close DATA; 35 ok(scalar @match > 0 ? 0 : 1, 36 "checking that storeutl didn't ask for a passphrase"); 37