Fix no-des
[openssl.git] / test / recipes / 80-test_pkcs12.t
1 #! /usr/bin/env perl
2 # Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the OpenSSL license (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 use strict;
10 use warnings;
11
12 use OpenSSL::Test qw/:DEFAULT srctop_file/;
13 use OpenSSL::Test::Utils;
14
15 use Encode;
16
17 setup("test_pkcs12");
18
19 plan skip_all => "The PKCS12 command line utility is not supported by this OpenSSL build"
20     if disabled("des");
21
22 plan tests => 1;
23
24 my $pass = "σύνθημα γνώρισμα";
25
26 my $savedcp;
27 if (eval { require Win32::Console; 1; }) {
28     # Trouble is that Win32 perl uses CreateProcessA, which
29     # makes it problematic to pass non-ASCII arguments. The only
30     # feasible option is to pick one language, set corresponding
31     # code page and reencode the problematic string...
32
33     $savedcp = Win32::Console::OutputCP();
34     Win32::Console::OutputCP(1253);
35     $pass = Encode::encode("cp1253",Encode::decode("utf-8",$pass));
36 } else {
37     # Running MinGW tests transparenly under Wine apparently requires
38     # UTF-8 locale...
39
40     foreach(`locale -a`) {
41         s/\R$//;
42         if ($_ =~ m/^C\.UTF\-?8/i) {
43             $ENV{LC_ALL} = $_;
44             last;
45         }
46     }
47 }
48
49 # just see that we can read shibboleth.pfx protected with $pass
50 ok(run(app(["openssl", "pkcs12", "-noout",
51             "-password", "pass:$pass",
52             "-in", srctop_file("test", "shibboleth.pfx")])),
53    "test_pkcs12");
54
55 Win32::Console::OutputCP($savedcp) if (defined($savedcp));