xref: /freebsd/crypto/openssl/test/recipes/90-test_store_cases.t (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert#! /usr/bin/env perl
2*e0c4386eSCy Schubert# Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert#
4*e0c4386eSCy Schubert# Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert# this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert# in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert# https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert
9*e0c4386eSCy Schubert# This collects specific use cases, and tests our handling
10*e0c4386eSCy Schubert
11*e0c4386eSCy Schubertuse File::Spec::Functions;
12*e0c4386eSCy Schubertuse File::Copy;
13*e0c4386eSCy Schubertuse MIME::Base64;
14*e0c4386eSCy Schubertuse OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file bldtop_dir
15*e0c4386eSCy Schubert                     data_file);
16*e0c4386eSCy Schubertuse OpenSSL::Test::Utils;
17*e0c4386eSCy Schubert
18*e0c4386eSCy Schubertmy $test_name = "test_store_cases";
19*e0c4386eSCy Schubertsetup($test_name);
20*e0c4386eSCy Schubert
21*e0c4386eSCy Schubertplan tests => 2;
22*e0c4386eSCy Schubert
23*e0c4386eSCy Schubertmy $stderr;
24*e0c4386eSCy Schubert
25*e0c4386eSCy Schubert# The case of the garbage PKCS#12 DER file where a passphrase was
26*e0c4386eSCy Schubert# prompted for.  That should not have happened.
27*e0c4386eSCy Schubert$stderr = 'garbage-pkcs12.stderr.txt';
28*e0c4386eSCy Schubertok(!run(app(['openssl', 'storeutl', '-passin', 'pass:invalidapass',
29*e0c4386eSCy Schubert             data_file('garbage-pkcs12.p12')],
30*e0c4386eSCy Schubert            stderr => $stderr)),
31*e0c4386eSCy Schubert   "checking that storeutl fails when given a garbage pkcs12 file");
32*e0c4386eSCy Schubertopen DATA, $stderr;
33*e0c4386eSCy Schubert@match = grep /try_pkcs12:.*?:maybe wrong password$/, <DATA>;
34*e0c4386eSCy Schubertclose DATA;
35*e0c4386eSCy Schubertok(scalar @match > 0 ? 0 : 1,
36*e0c4386eSCy Schubert   "checking that storeutl didn't ask for a passphrase");
37