2015-04-17 18:15:22 +00:00
|
|
|
#! /usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use File::Spec;
|
2016-01-30 00:05:33 +00:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file/;
|
2015-04-17 18:15:22 +00:00
|
|
|
|
|
|
|
setup("test_req");
|
|
|
|
|
|
|
|
plan tests => 3;
|
|
|
|
|
2016-01-30 00:05:33 +00:00
|
|
|
require_ok(srctop_file('test','recipes','tconversion.pl'));
|
2015-04-17 18:15:22 +00:00
|
|
|
|
2016-01-30 00:05:33 +00:00
|
|
|
my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf"));
|
2015-04-17 18:15:22 +00:00
|
|
|
|
|
|
|
run_conversion('req conversions',
|
|
|
|
"testreq.pem");
|
|
|
|
run_conversion('req conversions -- testreq2',
|
|
|
|
"testreq2.pem");
|
|
|
|
|
|
|
|
sub run_conversion {
|
|
|
|
my $title = shift;
|
|
|
|
my $reqfile = shift;
|
|
|
|
|
|
|
|
subtest $title => sub {
|
|
|
|
run(app(["openssl", @openssl_args,
|
|
|
|
"-in", $reqfile, "-inform", "p",
|
|
|
|
"-noout", "-text"],
|
|
|
|
stderr => "req-check.err", stdout => undef));
|
|
|
|
open DATA, "req-check.err";
|
|
|
|
SKIP: {
|
|
|
|
plan skip_all => "skipping req conversion test for $reqfile"
|
2015-10-12 20:24:27 +00:00
|
|
|
if grep /Unknown Public Key/, map { s/\R//; } <DATA>;
|
2015-04-17 18:15:22 +00:00
|
|
|
|
|
|
|
tconversion("req", "testreq.pem", @openssl_args);
|
|
|
|
}
|
|
|
|
close DATA;
|
|
|
|
unlink "req-check.err";
|
|
|
|
|
|
|
|
done_testing();
|
|
|
|
};
|
|
|
|
}
|