setup("test_x509");
-plan tests => 14;
+plan tests => 15;
require_ok(srctop_file('test','recipes','tconversion.pl'));
my ($expected, $cert, @opts) = @_;
my $infile = srctop_file('test', 'certs', $cert);
my @args = qw(openssl x509 -in);
- push(@args, "$infile", @opts);
+ push(@args, $infile, @opts);
my $tmpfile = 'out.txt';
- my $res = !run(app([@args], stderr => $tmpfile));
+ my $res = grep(/-text/, @opts) ? run(app([@args], stdout => $tmpfile))
+ : !run(app([@args], stderr => $tmpfile));
my $found = 0;
open(my $in, '<', $tmpfile) or die "Could not open file $tmpfile";
while(<$in>) {
$found = 1 if m/$expected/; # output must include $expected
}
close $in;
- unlink $tmpfile;
+ # $tmpfile is kept to help with investigation in case of failure
return $res && $found;
}
"load root-cert errors");
ok(test_errors("RC2-40-CBC", "v3-certs-RC2.p12", '-passin', 'pass:v3-certs'),
"load v3-certs-RC2 no asn1 errors");
+SKIP: {
+ skip "sm2 not disabled", 1 if !disabled("sm2");
+
+ ok(test_errors("unknown group|unsupported algorithm", "sm2.pem", '-text'),
+ "error loading unsupported sm2 cert");
+}