2016-08-22 23:04:47 +08:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the OpenSSL license (the "License"). You may not use
|
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2016-07-26 07:46:03 +08:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
2016-08-22 23:04:47 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
|
|
|
|
2016-07-26 07:46:03 +08:00
|
|
|
use Encode;
|
|
|
|
|
|
|
|
setup("test_pkcs12");
|
|
|
|
|
2016-08-22 23:04:47 +08:00
|
|
|
plan skip_all => "The PKCS12 command line utility is not supported by this OpenSSL build"
|
|
|
|
if disabled("des");
|
|
|
|
|
2016-07-26 07:46:03 +08:00
|
|
|
my $pass = "σύνθημα γνώρισμα";
|
|
|
|
|
|
|
|
my $savedcp;
|
2016-08-23 15:45:03 +08:00
|
|
|
if (eval { require Win32::API; 1; }) {
|
2016-07-26 07:46:03 +08:00
|
|
|
# Trouble is that Win32 perl uses CreateProcessA, which
|
2016-08-23 15:45:03 +08:00
|
|
|
# makes it problematic to pass non-ASCII arguments, from perl[!]
|
|
|
|
# that is. This is because CreateProcessA is just a wrapper for
|
|
|
|
# CreateProcessW and will call MultiByteToWideChar and use
|
|
|
|
# system default locale. Since we attempt Greek pass-phrase
|
|
|
|
# conversion can be done only with Greek locale.
|
2016-07-26 07:46:03 +08:00
|
|
|
|
2016-08-23 15:45:03 +08:00
|
|
|
Win32::API->Import("kernel32","UINT GetSystemDefaultLCID()");
|
|
|
|
if (GetSystemDefaultLCID() != 0x408) {
|
|
|
|
plan skip_all => "Non-Greek system locale";
|
|
|
|
} else {
|
|
|
|
# Ensure correct code page so that VERBOSE output is right.
|
|
|
|
Win32::API->Import("kernel32","UINT GetConsoleOutputCP()");
|
|
|
|
Win32::API->Import("kernel32","BOOL SetConsoleOutputCP(UINT cp)");
|
|
|
|
$savedcp = GetConsoleOutputCP();
|
|
|
|
SetConsoleOutputCP(1253);
|
|
|
|
$pass = Encode::encode("cp1253",Encode::decode("utf-8",$pass));
|
|
|
|
}
|
2016-07-26 22:42:41 +08:00
|
|
|
} else {
|
|
|
|
# Running MinGW tests transparenly under Wine apparently requires
|
|
|
|
# UTF-8 locale...
|
|
|
|
|
|
|
|
foreach(`locale -a`) {
|
|
|
|
s/\R$//;
|
|
|
|
if ($_ =~ m/^C\.UTF\-?8/i) {
|
|
|
|
$ENV{LC_ALL} = $_;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2016-07-26 07:46:03 +08:00
|
|
|
}
|
2016-08-25 14:06:26 +08:00
|
|
|
$ENV{OPENSSL_WIN32_UTF8}=1;
|
2016-07-26 07:46:03 +08:00
|
|
|
|
2016-08-23 15:45:03 +08:00
|
|
|
plan tests => 1;
|
|
|
|
|
2016-07-26 07:46:03 +08:00
|
|
|
# just see that we can read shibboleth.pfx protected with $pass
|
|
|
|
ok(run(app(["openssl", "pkcs12", "-noout",
|
|
|
|
"-password", "pass:$pass",
|
|
|
|
"-in", srctop_file("test", "shibboleth.pfx")])),
|
|
|
|
"test_pkcs12");
|
|
|
|
|
2016-08-23 15:45:03 +08:00
|
|
|
SetConsoleOutputCP($savedcp) if (defined($savedcp));
|