Add a Certificate Policies Test
authorMatt Caswell <matt@openssl.org>
Tue, 7 Mar 2023 17:07:57 +0000 (17:07 +0000)
committerTomas Mraz <tomas@openssl.org>
Tue, 28 Mar 2023 11:45:14 +0000 (13:45 +0200)
Test that a valid certificate policy is accepted and that an invalid
certificate policy is rejected. Specifically we are checking that a
leaf certificate with an invalid policy is detected.

Related-to: CVE-2023-0465
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20586)

test/recipes/25-test_verify.t

index e8464df2605c117cdf4e66a2a277017daf2d5a24..f69af793e469954fb1ae07122604cc2cf1584f6c 100644 (file)
@@ -29,7 +29,7 @@ sub verify {
     run(app([@args]));
 }
 
-plan tests => 173;
+plan tests => 175;
 
 # Canonical success
 ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
@@ -536,3 +536,14 @@ SKIP: {
     ok(run(app([ qw(openssl verify -trusted), $rsapluscert_file, $cert_file ])),
        'Mixed key + cert file test');
 }
+
+# Certificate Policies
+ok(verify("ee-cert-policies", "", ["root-cert"], ["ca-pol-cert"],
+          "-policy_check", "-policy", "1.3.6.1.4.1.16604.998855.1",
+          "-explicit_policy"),
+   "Certificate policy");
+
+ok(!verify("ee-cert-policies-bad", "", ["root-cert"], ["ca-pol-cert"],
+           "-policy_check", "-policy", "1.3.6.1.4.1.16604.998855.1",
+           "-explicit_policy"),
+   "Bad certificate policy");