Add PKCS#12 UTF-8 interoperability test.
[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 }
24
25 # just see that we can read shibboleth.pfx protected with $pass
26 ok(run(app(["openssl", "pkcs12", "-noout",
27             "-password", "pass:$pass",
28             "-in", srctop_file("test", "shibboleth.pfx")])),
29    "test_pkcs12");
30
31 Win32::Console::OutputCP($savedcp) if (defined($savedcp));