]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add tests for conf_diagnostics
authorTomas Mraz <tomas@openssl.org>
Thu, 2 May 2024 13:58:11 +0000 (15:58 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 9 May 2024 07:20:58 +0000 (09:20 +0200)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24275)

test/context_internal_test.c
test/recipes/90-test_sysdefault.t
test/recipes/90-test_sysdefault_data/sysdefault-bad.cnf [moved from test/sysdefault.cnf with 100% similarity]
test/recipes/90-test_sysdefault_data/sysdefault-ignore.cnf [new file with mode: 0644]
test/recipes/90-test_sysdefault_data/sysdefault.cnf [new file with mode: 0644]

index 8fea53fee168d2dcd0e230f31dd735511ae3bd1b..c829d8111d0474a424146ea26e77e7106687364d 100644 (file)
@@ -48,8 +48,36 @@ static int test_set0_default(void)
     return testresult;
 }
 
+static int test_set_get_conf_diagnostics(void)
+{
+    OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new();
+    int res = 0;
+
+    if (!TEST_ptr(ctx))
+        goto err;
+
+    if (!TEST_false(OSSL_LIB_CTX_get_conf_diagnostics(ctx)))
+        goto err;
+
+    OSSL_LIB_CTX_set_conf_diagnostics(ctx, 1);
+
+    if (!TEST_true(OSSL_LIB_CTX_get_conf_diagnostics(ctx)))
+        goto err;
+
+    OSSL_LIB_CTX_set_conf_diagnostics(ctx, 0);
+
+    if (!TEST_false(OSSL_LIB_CTX_get_conf_diagnostics(ctx)))
+        goto err;
+
+    res = 1;
+ err:
+    OSSL_LIB_CTX_free(ctx);
+    return res;
+}
+
 int setup_tests(void)
 {
     ADD_TEST(test_set0_default);
+    ADD_TEST(test_set_get_conf_diagnostics);
     return 1;
 }
index 308a592abac960a2cfcbb8ebddd13d2338a4a633..6984bc10673eb0e0cab20e2eee1e17500e9a2d3c 100644 (file)
@@ -8,7 +8,7 @@
 
 
 use OpenSSL::Test::Utils;
-use OpenSSL::Test qw/:DEFAULT srctop_file/;
+use OpenSSL::Test qw/:DEFAULT data_file/;
 
 my $test_name = "test_sysdefault";
 setup($test_name);
@@ -16,8 +16,16 @@ setup($test_name);
 plan skip_all => "$test_name is not supported in this build"
     if disabled("tls1_2") || disabled("rsa");
 
-plan tests => 1;
+plan tests => 3;
 
-$ENV{OPENSSL_CONF} = srctop_file("test", "sysdefault.cnf");
+$ENV{OPENSSL_CONF} = data_file("sysdefault.cnf");
+
+ok(run(test(["sysdefaulttest"])), "sysdefaulttest");
+
+$ENV{OPENSSL_CONF} = data_file("sysdefault-bad.cnf");
+
+ok(!run(test(["sysdefaulttest"])), "sysdefaulttest");
+
+$ENV{OPENSSL_CONF} = data_file("sysdefault-ignore.cnf");
 
 ok(run(test(["sysdefaulttest"])), "sysdefaulttest");
diff --git a/test/recipes/90-test_sysdefault_data/sysdefault-ignore.cnf b/test/recipes/90-test_sysdefault_data/sysdefault-ignore.cnf
new file mode 100644 (file)
index 0000000..2b04caf
--- /dev/null
@@ -0,0 +1,23 @@
+# Configuration file to test system default SSL configuration
+
+# We ignore configuration errors with config_diagnostics unset
+# config_diagnostics = 1
+
+openssl_conf = default_conf
+
+[ default_conf ]
+
+ssl_conf = ssl_sect
+oid_section = oid_sect
+
+[oid_sect]
+new-sig-oid = 1.1.1.1.1.1.1.1.1.1.1.1.1.1
+
+[ssl_sect]
+
+system_default = ssl_default_sect
+
+[ssl_default_sect]
+SignatureAlgorithms = RSA+SHA256:nonex
+MaxProtocol = TLSv1.2
+MinProtocol = TLSv1.2
diff --git a/test/recipes/90-test_sysdefault_data/sysdefault.cnf b/test/recipes/90-test_sysdefault_data/sysdefault.cnf
new file mode 100644 (file)
index 0000000..f2cfa10
--- /dev/null
@@ -0,0 +1,23 @@
+# Configuration file to test system default SSL configuration
+
+# Comment out the next line to ignore configuration errors
+config_diagnostics = 1
+
+openssl_conf = default_conf
+
+[ default_conf ]
+
+ssl_conf = ssl_sect
+oid_section = oid_sect
+
+[oid_sect]
+new-sig-oid = 1.1.1.1.1.1.1.1.1.1.1.1.1.1
+
+[ssl_sect]
+
+system_default = ssl_default_sect
+
+[ssl_default_sect]
+SignatureAlgorithms = RSA+SHA256:?nonex
+MaxProtocol = TLSv1.2
+MinProtocol = TLSv1.2