]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/80-test_pkcs12.t
Add ECDSA to providers
[thirdparty/openssl.git] / test / recipes / 80-test_pkcs12.t
CommitLineData
1c55e372 1#! /usr/bin/env perl
0d664759 2# Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
1c55e372 3#
909f1a2e 4# Licensed under the Apache License 2.0 (the "License"). You may not use
1c55e372
MC
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
70bf33d1
AP
9use strict;
10use warnings;
11
12use OpenSSL::Test qw/:DEFAULT srctop_file/;
1c55e372
MC
13use OpenSSL::Test::Utils;
14
70bf33d1
AP
15use Encode;
16
17setup("test_pkcs12");
18
1c55e372
MC
19plan skip_all => "The PKCS12 command line utility is not supported by this OpenSSL build"
20 if disabled("des");
21
70bf33d1
AP
22my $pass = "σύνθημα γνώρισμα";
23
24my $savedcp;
652c52a6 25if (eval { require Win32::API; 1; }) {
70bf33d1 26 # Trouble is that Win32 perl uses CreateProcessA, which
652c52a6
AP
27 # makes it problematic to pass non-ASCII arguments, from perl[!]
28 # that is. This is because CreateProcessA is just a wrapper for
29 # CreateProcessW and will call MultiByteToWideChar and use
30 # system default locale. Since we attempt Greek pass-phrase
31 # conversion can be done only with Greek locale.
70bf33d1 32
652c52a6
AP
33 Win32::API->Import("kernel32","UINT GetSystemDefaultLCID()");
34 if (GetSystemDefaultLCID() != 0x408) {
35 plan skip_all => "Non-Greek system locale";
36 } else {
37 # Ensure correct code page so that VERBOSE output is right.
38 Win32::API->Import("kernel32","UINT GetConsoleOutputCP()");
39 Win32::API->Import("kernel32","BOOL SetConsoleOutputCP(UINT cp)");
40 $savedcp = GetConsoleOutputCP();
41 SetConsoleOutputCP(1253);
42 $pass = Encode::encode("cp1253",Encode::decode("utf-8",$pass));
43 }
d4c499f5
AP
44} elsif ($^O eq "MSWin32") {
45 plan skip_all => "Win32::API unavailable";
1194ea8d 46} else {
46f4e1be 47 # Running MinGW tests transparently under Wine apparently requires
1194ea8d
AP
48 # UTF-8 locale...
49
50 foreach(`locale -a`) {
51 s/\R$//;
52 if ($_ =~ m/^C\.UTF\-?8/i) {
53 $ENV{LC_ALL} = $_;
54 last;
55 }
56 }
70bf33d1 57}
fb5d9f1d 58$ENV{OPENSSL_WIN32_UTF8}=1;
70bf33d1 59
652c52a6
AP
60plan tests => 1;
61
70bf33d1
AP
62# just see that we can read shibboleth.pfx protected with $pass
63ok(run(app(["openssl", "pkcs12", "-noout",
64 "-password", "pass:$pass",
65 "-in", srctop_file("test", "shibboleth.pfx")])),
66 "test_pkcs12");
67
652c52a6 68SetConsoleOutputCP($savedcp) if (defined($savedcp));