summaryrefslogtreecommitdiffstats
path: root/test/recipes/90-test_store.t
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-11-30 10:44:34 +0100
committerRichard Levitte <levitte@openssl.org>2020-12-02 20:19:41 +0100
commit0a3b330cf09dd3746f4f9c5bb82d9bbcfff809c1 (patch)
tree614dea92e921b5b56142fa96e6cc704388b23df2 /test/recipes/90-test_store.t
parentAPPS: Adapt load_key() and load_pubkey() for the engine: loader (diff)
downloadopenssl-0a3b330cf09dd3746f4f9c5bb82d9bbcfff809c1.tar.xz
openssl-0a3b330cf09dd3746f4f9c5bb82d9bbcfff809c1.zip
Add test to demonstrate the app's new engine key loading
This adds a bit of functionality in ossltest, so it can now be used to load PEM files. It takes the file name as key ID, but just to make sure faults aren't ignored, it requires all file names to be prefixed with 'ot:'. Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/13570)
Diffstat (limited to 'test/recipes/90-test_store.t')
-rw-r--r--test/recipes/90-test_store.t41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/recipes/90-test_store.t b/test/recipes/90-test_store.t
index 05e4b341f5..a36a59fd8b 100644
--- a/test/recipes/90-test_store.t
+++ b/test/recipes/90-test_store.t
@@ -9,7 +9,8 @@
use File::Spec::Functions;
use File::Copy;
use MIME::Base64;
-use OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file data_file);
+use OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file bldtop_dir
+ data_file);
use OpenSSL::Test::Utils;
my $test_name = "test_store";
@@ -31,6 +32,9 @@ my @src_files =
"test/testrsapub.pem",
"test/testcrl.pem",
"apps/server.pem" );
+my @src_rsa_files =
+ ( "test/testrsa.pem",
+ "test/testrsapub.pem" );
my @generated_files =
(
### generated from the source files
@@ -106,11 +110,46 @@ my $n = scalar @methods
+ 3
+ 11 );
+my $do_test_ossltest_store =
+ !(disabled("engine") || disabled("dynamic-engine"));
+
+if ($do_test_ossltest_store) {
+ # test loading with apps 'org.openssl.engine:' loader, using the
+ # ossltest engine.
+ $n += 4 * scalar @src_rsa_files;
+}
+
plan skip_all => "No plan" if $n == 0;
plan tests => $n;
indir "store_$$" => sub {
+ if ($do_test_ossltest_store) {
+ # ossltest loads PEM files, with names prefixed with 'ot:'.
+ # This prefix ensures that the files are, in fact, loaded through
+ # that engine and not mistakenly going through the 'file:' loader.
+
+ my $engine_scheme = 'org.openssl.engine:';
+ $ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
+
+ foreach (@src_rsa_files) {
+ my $file = srctop_file($_);
+ my $file_abs = to_abs_file($file);
+ my @pubin = $_ =~ m|pub\.pem$| ? ("-pubin") : ();
+
+ ok(run(app(["openssl", "rsa", "-text", "-noout", @pubin,
+ "-engine", "ossltest", "-inform", "engine",
+ "-in", "ot:$file"])));
+ ok(run(app(["openssl", "rsa", "-text", "-noout", @pubin,
+ "-engine", "ossltest", "-inform", "engine",
+ "-in", "ot:$file_abs"])));
+ ok(run(app(["openssl", "rsa", "-text", "-noout", @pubin,
+ "-in", "${engine_scheme}ossltest:ot:$file"])));
+ ok(run(app(["openssl", "rsa", "-text", "-noout", @pubin,
+ "-in", "${engine_scheme}ossltest:ot:$file_abs"])));
+ }
+ }
+
SKIP:
{
init() or die "init failed";