+
+sub test_errors { # actually tests diagnostics of OSSL_STORE
+ my ($expected, $cert, @opts) = @_;
+ my $infile = srctop_file('test', 'certs', $cert);
+ my @args = qw(openssl x509 -in);
+ push(@args, "$infile", @opts);
+ my $tmpfile = 'out.txt';
+ my $res = !run(app([@args], stderr => $tmpfile));
+ my $found = 0;
+ open(my $in, '<', $tmpfile) or die "Could not open file $tmpfile";
+ while(<$in>) {
+ print; # this may help debugging
+ $res &&= !m/asn1 encoding/; # output must not include ASN.1 parse errors
+ $found = 1 if m/$expected/; # output must include $expected
+ }
+ close $in;
+ unlink $tmpfile;
+ return $res && $found;
+}
+
+ok(test_errors("Can't open any-dir/", "root-cert.pem", '-out', 'any-dir/'),
+ "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");