crypto/pkcs12: facilitate accessing data with non-interoperable password.
[openssl.git] / test / recipes / 80-test_pkcs12.t
1 use strict;
2 use warnings;
3
4 use OpenSSL::Test qw/:DEFAULT srctop_file/;
5 use Encode;
6
7 setup("test_pkcs12");
8
9 plan tests => 1;
10
11 my $pass = "σύνθημα γνώρισμα";
12
13 my $savedcp;
14 if (eval { require Win32::Console; 1; }) {
15     # Trouble is that Win32 perl uses CreateProcessA, which
16     # makes it problematic to pass non-ASCII arguments. The only
17     # feasible option is to pick one language, set corresponding
18     # code page and reencode the problematic string...
19
20     $savedcp = Win32::Console::OutputCP();
21     Win32::Console::OutputCP(1253);
22     $pass = Encode::encode("cp1253",Encode::decode("utf-8",$pass));
23 } else {
24     # Running MinGW tests transparenly under Wine apparently requires
25     # UTF-8 locale...
26
27     foreach(`locale -a`) {
28         s/\R$//;
29         if ($_ =~ m/^C\.UTF\-?8/i) {
30             $ENV{LC_ALL} = $_;
31             last;
32         }
33     }
34 }
35
36 # just see that we can read shibboleth.pfx protected with $pass
37 ok(run(app(["openssl", "pkcs12", "-noout",
38             "-password", "pass:$pass",
39             "-in", srctop_file("test", "shibboleth.pfx")])),
40    "test_pkcs12");
41
42 Win32::Console::OutputCP($savedcp) if (defined($savedcp));