2016-04-22 19:21:51 +08:00
|
|
|
#! /usr/bin/env perl
|
2021-02-18 22:57:13 +08:00
|
|
|
# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
|
2016-04-22 19:21:51 +08:00
|
|
|
#
|
2018-12-06 20:05:25 +08:00
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
2016-04-22 19:21:51 +08:00
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
2015-04-18 02:15:22 +08:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use File::Spec::Functions qw/canonpath/;
|
2021-09-03 21:00:47 +08:00
|
|
|
use File::Copy;
|
2022-06-20 18:18:44 +08:00
|
|
|
use OpenSSL::Test qw/:DEFAULT srctop_file bldtop_dir ok_nofips with/;
|
2017-04-27 01:46:31 +08:00
|
|
|
use OpenSSL::Test::Utils;
|
2015-04-18 02:15:22 +08:00
|
|
|
|
|
|
|
setup("test_verify");
|
|
|
|
|
2016-01-15 07:10:27 +08:00
|
|
|
sub verify {
|
2016-01-28 16:01:45 +08:00
|
|
|
my ($cert, $purpose, $trusted, $untrusted, @opts) = @_;
|
2016-01-15 07:10:27 +08:00
|
|
|
my @path = qw(test certs);
|
2021-03-02 20:20:38 +08:00
|
|
|
my @args = qw(openssl verify -auth_level 1);
|
|
|
|
push(@args, "-purpose", $purpose) if $purpose ne "";
|
|
|
|
push(@args, @opts);
|
2016-01-30 08:05:33 +08:00
|
|
|
for (@$trusted) { push(@args, "-trusted", srctop_file(@path, "$_.pem")) }
|
|
|
|
for (@$untrusted) { push(@args, "-untrusted", srctop_file(@path, "$_.pem")) }
|
|
|
|
push(@args, srctop_file(@path, "$cert.pem"));
|
2016-01-15 07:10:27 +08:00
|
|
|
run(app([@args]));
|
|
|
|
}
|
2015-10-13 04:16:07 +08:00
|
|
|
|
2023-03-08 01:07:57 +08:00
|
|
|
plan tests => 185;
|
2015-04-18 02:15:22 +08:00
|
|
|
|
2016-01-15 07:10:27 +08:00
|
|
|
# Canonical success
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", ["root-cert"], ["ca-cert"]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept compat trust");
|
2016-01-15 07:10:27 +08:00
|
|
|
|
|
|
|
# Root CA variants
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-nonca)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail trusted non-ca root");
|
2016-01-30 01:22:21 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(nroot+serverAuth)], [qw(ca-cert)]),
|
|
|
|
"fail server trust non-ca root");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(nroot+anyEKU)], [qw(ca-cert)]),
|
|
|
|
"fail wildcard trust non-ca root");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert2)], [qw(ca-cert)]),
|
2016-01-15 07:10:27 +08:00
|
|
|
"fail wrong root key");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-name2)], [qw(ca-cert)]),
|
2016-01-15 07:10:27 +08:00
|
|
|
"fail wrong root DN");
|
2016-01-29 15:28:43 +08:00
|
|
|
|
2020-09-22 14:36:22 +08:00
|
|
|
# Critical extensions
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert-noncrit-unknown-ext", "", ["root-cert"], ["ca-cert"]),
|
2020-09-22 14:36:22 +08:00
|
|
|
"accept non-critical unknown extension");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert-crit-unknown-ext", "", ["root-cert"], ["ca-cert"]),
|
2020-09-22 14:36:22 +08:00
|
|
|
"reject critical unknown extension");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert-ocsp-nocheck", "", ["root-cert"], ["ca-cert"]),
|
2020-09-22 14:36:22 +08:00
|
|
|
"accept critical OCSP No Check");
|
|
|
|
|
2016-01-29 15:28:43 +08:00
|
|
|
# Explicit trust/purpose combinations
|
|
|
|
#
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(sroot-cert)], [qw(ca-cert)]),
|
|
|
|
"accept server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(croot-cert)], [qw(ca-cert)]),
|
|
|
|
"fail client purpose");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root+serverAuth)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept server trust");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(sroot+serverAuth)], [qw(ca-cert)]),
|
|
|
|
"accept server trust with server purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(croot+serverAuth)], [qw(ca-cert)]),
|
|
|
|
"accept server trust with client purpose");
|
|
|
|
# Wildcard trust
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root+anyEKU)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept wildcard trust");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(sroot+anyEKU)], [qw(ca-cert)]),
|
|
|
|
"accept wildcard trust with server purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(croot+anyEKU)], [qw(ca-cert)]),
|
|
|
|
"accept wildcard trust with client purpose");
|
|
|
|
# Inapplicable mistrust
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-clientAuth)], [qw(ca-cert)]),
|
|
|
|
"accept client mistrust");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(sroot-clientAuth)], [qw(ca-cert)]),
|
|
|
|
"accept client mistrust with server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(croot-clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client mistrust with client purpose");
|
|
|
|
# Inapplicable trust
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root+clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client trust");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(sroot+clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client trust with server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(croot+clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client trust with client purpose");
|
|
|
|
# Server mistrust
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-serverAuth)], [qw(ca-cert)]),
|
2016-01-15 07:10:27 +08:00
|
|
|
"fail rejected EKU");
|
2016-01-29 15:28:43 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(sroot-serverAuth)], [qw(ca-cert)]),
|
|
|
|
"fail server mistrust with server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(croot-serverAuth)], [qw(ca-cert)]),
|
|
|
|
"fail server mistrust with client purpose");
|
|
|
|
# Wildcard mistrust
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-anyEKU)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail wildcard mistrust");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(sroot-anyEKU)], [qw(ca-cert)]),
|
|
|
|
"fail wildcard mistrust with server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(croot-anyEKU)], [qw(ca-cert)]),
|
|
|
|
"fail wildcard mistrust with client purpose");
|
2016-01-15 07:10:27 +08:00
|
|
|
|
2016-01-28 16:01:45 +08:00
|
|
|
# Check that trusted-first is on by setting up paths to different roots
|
|
|
|
# depending on whether the intermediate is the trusted or untrusted one.
|
|
|
|
#
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-serverAuth root-cert2 ca-root2)],
|
|
|
|
[qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept trusted-first path");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert root2+serverAuth ca-root2)],
|
|
|
|
[qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept trusted-first path with server trust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert root2-serverAuth ca-root2)],
|
|
|
|
[qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail trusted-first path with server mistrust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert root2+clientAuth ca-root2)],
|
|
|
|
[qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail trusted-first path with client trust");
|
2016-01-28 16:01:45 +08:00
|
|
|
|
2016-01-15 07:10:27 +08:00
|
|
|
# CA variants
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-nonca)]),
|
2016-01-30 01:22:21 +08:00
|
|
|
"fail non-CA untrusted intermediate");
|
2016-03-30 07:40:03 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-nonbc)]),
|
|
|
|
"fail non-CA untrusted intermediate");
|
2016-01-30 01:22:21 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-nonca)], []),
|
2016-03-30 07:40:03 +08:00
|
|
|
"fail non-CA trust-store intermediate");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-nonbc)], []),
|
|
|
|
"fail non-CA trust-store intermediate");
|
2016-01-30 01:22:21 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert nca+serverAuth)], []),
|
|
|
|
"fail non-CA server trust intermediate");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert nca+anyEKU)], []),
|
|
|
|
"fail non-CA wildcard trust intermediate");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-cert2)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail wrong intermediate CA key");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-name2)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail wrong intermediate CA DN");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert)], [qw(ca-root2)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail wrong intermediate CA issuer");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [], [qw(ca-cert)], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail untrusted partial chain");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(ca-cert)], [], "-partial_chain"),
|
|
|
|
"accept trusted partial chain");
|
2020-12-01 21:22:16 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(ca-expired)], [], "-partial_chain"),
|
|
|
|
"reject expired trusted partial chain"); # this check is beyond RFC 5280
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-expired)], [qw(ca-cert)]),
|
|
|
|
"reject expired trusted root"); # this check is beyond RFC 5280
|
2016-01-29 15:28:43 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(sca-cert)], [], "-partial_chain"),
|
|
|
|
"accept partial chain with server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(cca-cert)], [], "-partial_chain"),
|
|
|
|
"fail partial chain with client purpose");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(ca+serverAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept server trust partial chain");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(cca+serverAuth)], [], "-partial_chain"),
|
|
|
|
"accept server trust client purpose partial chain");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(ca-clientAuth)], [], "-partial_chain"),
|
|
|
|
"accept client mistrust partial chain");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(ca+anyEKU)], [], "-partial_chain"),
|
|
|
|
"accept wildcard trust partial chain");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [], [qw(ca+serverAuth)], "-partial_chain"),
|
|
|
|
"fail untrusted partial issuer with ignored server trust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(ca-serverAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail server mistrust partial chain");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(ca+clientAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail client trust partial chain");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(ca-anyEKU)], [], "-partial_chain"),
|
|
|
|
"fail wildcard mistrust partial chain");
|
2016-01-15 07:10:27 +08:00
|
|
|
|
2016-01-28 16:01:45 +08:00
|
|
|
# We now test auxiliary trust even for intermediate trusted certs without
|
|
|
|
# -partial_chain. Note that "-trusted_first" is now always on and cannot
|
|
|
|
# be disabled.
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert ca+serverAuth)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept server trust");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert ca+anyEKU)], [qw(ca-cert)]),
|
|
|
|
"accept wildcard trust");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert sca-cert)], [qw(ca-cert)]),
|
|
|
|
"accept server purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert sca+serverAuth)], [qw(ca-cert)]),
|
|
|
|
"accept server trust and purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert sca+anyEKU)], [qw(ca-cert)]),
|
|
|
|
"accept wildcard trust and server purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert sca-clientAuth)], [qw(ca-cert)]),
|
|
|
|
"accept client mistrust and server purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert cca+serverAuth)], [qw(ca-cert)]),
|
|
|
|
"accept server trust and client purpose");
|
|
|
|
ok(verify("ee-cert", "sslserver", [qw(root-cert cca+anyEKU)], [qw(ca-cert)]),
|
|
|
|
"accept wildcard trust and client purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-cert)], [qw(ca-cert)]),
|
|
|
|
"fail client purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-anyEKU)], [qw(ca-cert)]),
|
|
|
|
"fail wildcard mistrust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert ca-serverAuth)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail server mistrust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert ca+clientAuth)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail client trust");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert sca+clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client trust and server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert cca+clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client trust and client purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-serverAuth)], [qw(ca-cert)]),
|
|
|
|
"fail server mistrust and client purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-clientAuth)], [qw(ca-cert)]),
|
|
|
|
"fail client mistrust and client purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert sca-serverAuth)], [qw(ca-cert)]),
|
|
|
|
"fail server mistrust and server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert sca-anyEKU)], [qw(ca-cert)]),
|
|
|
|
"fail wildcard mistrust and server purpose");
|
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(root-cert cca-anyEKU)], [qw(ca-cert)]),
|
|
|
|
"fail wildcard mistrust and client purpose");
|
2016-01-28 16:01:45 +08:00
|
|
|
|
2016-01-15 07:10:27 +08:00
|
|
|
# EE variants
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-client", "sslclient", [qw(root-cert)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept client chain");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-client", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail server leaf purpose");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslclient", [qw(root-cert)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail client leaf purpose");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert2", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail wrong intermediate CA key");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-name2", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail wrong intermediate CA DN");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-expired", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
|
2016-01-15 07:10:27 +08:00
|
|
|
"fail expired leaf");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(ee-cert)], [], "-partial_chain"),
|
2016-01-15 07:10:27 +08:00
|
|
|
"accept last-resort direct leaf match");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-client", "sslclient", [qw(ee-client)], [], "-partial_chain"),
|
2016-01-15 07:10:27 +08:00
|
|
|
"accept last-resort direct leaf match");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(ee-client)], [], "-partial_chain"),
|
2016-01-15 07:10:27 +08:00
|
|
|
"fail last-resort direct leaf non-match");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-cert", "sslserver", [qw(ee+serverAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept direct match with server trust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-cert", "sslserver", [qw(ee-serverAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"fail direct match with server mistrust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(verify("ee-client", "sslclient", [qw(ee+clientAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"accept direct match with client trust");
|
2016-01-28 16:01:45 +08:00
|
|
|
ok(!verify("ee-client", "sslclient", [qw(ee-clientAuth)], [], "-partial_chain"),
|
2016-01-29 15:28:43 +08:00
|
|
|
"reject direct match with client mistrust");
|
2020-04-03 16:24:40 +08:00
|
|
|
ok(verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"accept non-ca with pathlen:0 by default");
|
|
|
|
ok(!verify("ee-pathlen", "sslserver", [qw(root-cert)], [qw(ca-cert)], "-x509_strict"),
|
|
|
|
"reject non-ca with pathlen:0 with strict flag");
|
2016-03-19 10:09:41 +08:00
|
|
|
|
2022-06-17 19:11:31 +08:00
|
|
|
# EE veaiants wrt timestamp signing
|
|
|
|
ok(verify("ee-timestampsign-CABforum", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"accept timestampsign according to CAB forum");
|
|
|
|
ok(!verify("ee-timestampsign-CABforum-noncritxku", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to CAB forum with extendedKeyUsage not critical");
|
|
|
|
ok(!verify("ee-timestampsign-CABforum-serverauth", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to CAB forum with serverAuth");
|
|
|
|
ok(!verify("ee-timestampsign-CABforum-anyextkeyusage", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to CAB forum with anyExtendedKeyUsage");
|
|
|
|
ok(!verify("ee-timestampsign-CABforum-crlsign", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to CAB forum with cRLSign");
|
|
|
|
ok(!verify("ee-timestampsign-CABforum-keycertsign", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to CAB forum with keyCertSign");
|
|
|
|
ok(verify("ee-timestampsign-rfc3161", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"accept timestampsign according to RFC 3161");
|
|
|
|
ok(!verify("ee-timestampsign-rfc3161-noncritxku", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to RFC 3161 with extendedKeyUsage not critical");
|
|
|
|
ok(verify("ee-timestampsign-rfc3161-digsig", "timestampsign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"accept timestampsign according to RFC 3161 with digitalSignature");
|
|
|
|
|
2022-06-15 23:31:19 +08:00
|
|
|
# EE variants wrt code signing
|
|
|
|
ok(verify("ee-codesign", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"accept codesign");
|
|
|
|
ok(!verify("ee-codesign-serverauth", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail codesign with additional serverAuth");
|
|
|
|
ok(!verify("ee-codesign-anyextkeyusage", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail codesign with additional anyExtendedKeyUsage");
|
|
|
|
ok(!verify("ee-codesign-crlsign", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail codesign with additional cRLSign");
|
|
|
|
ok(!verify("ee-codesign-keycertsign", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail codesign with additional keyCertSign");
|
|
|
|
ok(!verify("ee-codesign-noncritical", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail codesign without critical KU");
|
|
|
|
ok(!verify("ee-cert", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail sslserver as code sign");
|
|
|
|
ok(!verify("ee-client", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail sslclient as codesign");
|
|
|
|
ok(!verify("ee-timestampsign-CABforum", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to CAB forum as codesign");
|
|
|
|
ok(!verify("ee-timestampsign-rfc3161", "codesign", [qw(root-cert)], [qw(ca-cert)]),
|
|
|
|
"fail timestampsign according to RFC 3161 as codesign");
|
|
|
|
|
2016-06-19 16:56:37 +08:00
|
|
|
# Proxy certificates
|
|
|
|
ok(!verify("pc1-cert", "sslclient", [qw(root-cert)], [qw(ee-client ca-cert)]),
|
|
|
|
"fail to accept proxy cert without -allow_proxy_certs");
|
|
|
|
ok(verify("pc1-cert", "sslclient", [qw(root-cert)], [qw(ee-client ca-cert)],
|
|
|
|
"-allow_proxy_certs"),
|
|
|
|
"accept proxy cert 1");
|
|
|
|
ok(verify("pc2-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
|
|
|
|
"-allow_proxy_certs"),
|
|
|
|
"accept proxy cert 2");
|
|
|
|
ok(!verify("bad-pc3-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
|
|
|
|
"-allow_proxy_certs"),
|
|
|
|
"fail proxy cert with incorrect subject");
|
|
|
|
ok(!verify("bad-pc4-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
|
|
|
|
"-allow_proxy_certs"),
|
|
|
|
"fail proxy cert with incorrect pathlen");
|
|
|
|
ok(verify("pc5-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
|
|
|
|
"-allow_proxy_certs"),
|
|
|
|
"accept proxy cert missing proxy policy");
|
|
|
|
ok(!verify("pc6-cert", "sslclient", [qw(root-cert)], [qw(pc1-cert ee-client ca-cert)],
|
|
|
|
"-allow_proxy_certs"),
|
|
|
|
"failed proxy cert where last CN was added as a multivalue RDN component");
|
|
|
|
|
2016-03-19 10:09:41 +08:00
|
|
|
# Security level tests
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "2"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept RSA 2048 chain at auth level 2");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "3"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"reject RSA 2048 root at auth level 3");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["root-cert-768"], ["ca-cert-768i"], "-auth_level", "0"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept RSA 768 root at auth level 0");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert", "", ["root-cert-768"], ["ca-cert-768i"]),
|
2016-03-19 10:09:41 +08:00
|
|
|
"reject RSA 768 root at auth level 1");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert-768i", "", ["root-cert"], ["ca-cert-768"], "-auth_level", "0"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept RSA 768 intermediate at auth level 0");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert-768i", "", ["root-cert"], ["ca-cert-768"]),
|
2016-03-19 10:09:41 +08:00
|
|
|
"reject RSA 768 intermediate at auth level 1");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert-768", "", ["root-cert"], ["ca-cert"], "-auth_level", "0"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept RSA 768 leaf at auth level 0");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert-768", "", ["root-cert"], ["ca-cert"]),
|
2016-03-19 10:09:41 +08:00
|
|
|
"reject RSA 768 leaf at auth level 1");
|
|
|
|
#
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["root-cert-md5"], ["ca-cert"], "-auth_level", "2"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept md5 self-signed TA at auth level 2");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["ca-cert-md5-any"], [], "-auth_level", "2"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept md5 intermediate TA at auth level 2");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["root-cert"], ["ca-cert-md5"], "-auth_level", "0"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept md5 intermediate at auth level 0");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert", "", ["root-cert"], ["ca-cert-md5"]),
|
2016-03-19 10:09:41 +08:00
|
|
|
"reject md5 intermediate at auth level 1");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert-md5", "", ["root-cert"], ["ca-cert"], "-auth_level", "0"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept md5 leaf at auth level 0");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert-md5", "", ["root-cert"], ["ca-cert"]),
|
2016-03-19 10:09:41 +08:00
|
|
|
"reject md5 leaf at auth level 1");
|
|
|
|
|
2020-09-11 15:09:29 +08:00
|
|
|
# Explicit vs named curve tests
|
|
|
|
SKIP: {
|
|
|
|
skip "EC is not supported by this OpenSSL build", 3
|
|
|
|
if disabled("ec");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert-ec-explicit", "", ["root-cert"],
|
2020-09-11 15:09:29 +08:00
|
|
|
["ca-cert-ec-named"]),
|
|
|
|
"reject explicit curve leaf with named curve intermediate");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert-ec-named-explicit", "", ["root-cert"],
|
2020-09-11 15:09:29 +08:00
|
|
|
["ca-cert-ec-explicit"]),
|
|
|
|
"reject named curve leaf with explicit curve intermediate");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert-ec-named-named", "", ["root-cert"],
|
2020-09-11 15:09:29 +08:00
|
|
|
["ca-cert-ec-named"]),
|
|
|
|
"accept named curve leaf with named curve intermediate");
|
|
|
|
}
|
2022-06-20 18:18:44 +08:00
|
|
|
# Same as above but with base provider used for decoding
|
|
|
|
SKIP: {
|
|
|
|
my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
|
|
|
|
my $provconf = srctop_file("test", "fips-and-base.cnf");
|
|
|
|
my $provpath = bldtop_dir("providers");
|
|
|
|
my @prov = ("-provider-path", $provpath);
|
2022-09-14 04:38:30 +08:00
|
|
|
|
|
|
|
skip "EC is not supported or FIPS is disabled", 3
|
|
|
|
if disabled("ec") || $no_fips;
|
|
|
|
|
|
|
|
run(test(["fips_version_test", "-config", $provconf, ">3.0.0"]),
|
|
|
|
capture => 1, statusvar => \my $exit);
|
|
|
|
skip "FIPS provider version is too old", 3
|
|
|
|
if !$exit;
|
|
|
|
|
2022-06-20 18:18:44 +08:00
|
|
|
$ENV{OPENSSL_CONF} = $provconf;
|
|
|
|
|
|
|
|
ok(!verify("ee-cert-ec-explicit", "", ["root-cert"],
|
|
|
|
["ca-cert-ec-named"], @prov),
|
|
|
|
"reject explicit curve leaf with named curve intermediate w/fips");
|
|
|
|
ok(!verify("ee-cert-ec-named-explicit", "", ["root-cert"],
|
|
|
|
["ca-cert-ec-explicit"], @prov),
|
|
|
|
"reject named curve leaf with explicit curve intermediate w/fips");
|
|
|
|
ok(verify("ee-cert-ec-named-named", "", ["root-cert"],
|
|
|
|
["ca-cert-ec-named"], @prov),
|
|
|
|
"accept named curve leaf with named curve intermediate w/fips");
|
|
|
|
|
|
|
|
delete $ENV{OPENSSL_CONF};
|
|
|
|
}
|
2020-09-11 15:09:29 +08:00
|
|
|
|
2016-03-19 10:09:41 +08:00
|
|
|
# Depth tests, note the depth limit bounds the number of CA certificates
|
|
|
|
# between the trust-anchor and the leaf, so, for example, with a root->ca->leaf
|
|
|
|
# chain, depth = 1 is sufficient, but depth == 0 is not.
|
|
|
|
#
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-verify_depth", "2"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept chain with verify_depth 2");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-verify_depth", "1"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept chain with verify_depth 1");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-cert", "", ["root-cert"], ["ca-cert"], "-verify_depth", "0"),
|
|
|
|
"reject chain with verify_depth 0");
|
|
|
|
ok(verify("ee-cert", "", ["ca-cert-md5-any"], [], "-verify_depth", "0"),
|
2016-03-19 10:09:41 +08:00
|
|
|
"accept md5 intermediate TA with verify_depth 0");
|
2016-06-22 20:36:08 +08:00
|
|
|
|
|
|
|
# Name Constraints tests.
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("alt1-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints everything permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("alt2-cert", "", ["root-cert"], ["ncca2-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints nothing excluded");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("alt3-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints nested test all permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("goodcn1-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2018-05-16 11:41:20 +08:00
|
|
|
"Name Constraints CNs permitted");
|
|
|
|
|
2021-12-03 23:28:31 +08:00
|
|
|
ok(verify("goodcn2-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
|
|
|
"Name Constraints CNs permitted - no SAN extension");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badcn1-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2018-05-16 11:41:20 +08:00
|
|
|
"Name Constraints CNs not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt1-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints hostname not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt2-cert", "", ["root-cert"], ["ncca2-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints hostname excluded");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt3-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints email address not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt4-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints subject email address not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt5-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints IP address not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt6-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints CN hostname not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt7-cert", "", ["root-cert"], ["ncca1-cert"], ),
|
2016-06-22 20:36:08 +08:00
|
|
|
"Name Constraints CN BMPSTRING hostname not permitted");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt8-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
|
2017-11-12 08:03:10 +08:00
|
|
|
"Name constraints nested DNS name not permitted 1");
|
2016-06-22 20:36:08 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt9-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
|
2017-11-12 08:03:10 +08:00
|
|
|
"Name constraints nested DNS name not permitted 2");
|
2016-06-22 20:36:08 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("badalt10-cert", "", ["root-cert"], ["ncca1-cert", "ncca3-cert"], ),
|
2017-11-12 08:03:10 +08:00
|
|
|
"Name constraints nested DNS name excluded");
|
2017-04-25 07:10:33 +08:00
|
|
|
|
2022-12-14 02:45:09 +08:00
|
|
|
ok(!verify("bad-othername-cert", "", ["root-cert"], ["nccaothername-cert"], ),
|
|
|
|
"CVE-2022-4203 type confusion test");
|
|
|
|
|
2021-06-03 18:50:48 +08:00
|
|
|
#Check that we get the expected failure return code
|
|
|
|
with({ exit_checker => sub { return shift == 2; } },
|
2021-06-07 18:16:25 +08:00
|
|
|
sub {
|
|
|
|
ok(verify("bad-othername-namec", "", ["bad-othername-namec-inter"], [],
|
|
|
|
"-partial_chain", "-attime", "1623060000"),
|
|
|
|
"Name constraints bad othername name constraint");
|
|
|
|
});
|
2021-06-03 18:50:48 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-pss-sha1-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "0"),
|
2020-01-03 06:25:27 +08:00
|
|
|
"Accept PSS signature using SHA1 at auth level 0");
|
2017-04-25 07:10:33 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-pss-sha256-cert", "", ["root-cert"], ["ca-cert"], ),
|
2017-04-25 07:10:33 +08:00
|
|
|
"CA with PSS signature using SHA256");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-pss-sha1-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "1"),
|
2020-01-03 06:25:27 +08:00
|
|
|
"Reject PSS signature using SHA1 and auth level 1");
|
2017-04-25 07:10:33 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-pss-sha256-cert", "", ["root-cert"], ["ca-cert"], "-auth_level", "2"),
|
2017-04-25 07:10:33 +08:00
|
|
|
"PSS signature using SHA256 and auth level 2");
|
2017-04-21 20:36:15 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-pss-cert", "", ["root-cert"], ["ca-pss-cert"], ),
|
2021-01-26 18:53:15 +08:00
|
|
|
"CA PSS signature");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-pss-wrong1.5-cert", "", ["root-cert"], ["ca-pss-cert"], ),
|
2021-01-26 18:53:15 +08:00
|
|
|
"CA producing regular PKCS#1 v1.5 signature with PSA-PSS key");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("many-names1", "", ["many-constraints"], ["many-constraints"], ),
|
2017-09-19 04:51:56 +08:00
|
|
|
"Too many names and constraints to check (1)");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("many-names2", "", ["many-constraints"], ["many-constraints"], ),
|
2017-09-19 04:51:56 +08:00
|
|
|
"Too many names and constraints to check (2)");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("many-names3", "", ["many-constraints"], ["many-constraints"], ),
|
2017-09-19 04:51:56 +08:00
|
|
|
"Too many names and constraints to check (3)");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("some-names1", "", ["many-constraints"], ["many-constraints"], ),
|
2017-09-19 04:51:56 +08:00
|
|
|
"Not too many names and constraints to check (1)");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("some-names2", "", ["many-constraints"], ["many-constraints"], ),
|
2017-09-19 04:51:56 +08:00
|
|
|
"Not too many names and constraints to check (2)");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("some-names2", "", ["many-constraints"], ["many-constraints"], ),
|
2017-09-19 04:51:56 +08:00
|
|
|
"Not too many names and constraints to check (3)");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("root-cert-rsa2", "", ["root-cert-rsa2"], [], "-check_ss_sig"),
|
2018-12-28 05:18:21 +08:00
|
|
|
"Public Key Algorithm rsa instead of rsaEncryption");
|
2017-09-19 04:51:56 +08:00
|
|
|
|
2021-05-27 20:10:58 +08:00
|
|
|
ok(verify("ee-self-signed", "", ["ee-self-signed"], [], "-attime", "1593565200"),
|
2021-03-02 20:20:38 +08:00
|
|
|
"accept trusted self-signed EE cert excluding key usage keyCertSign");
|
2021-06-08 17:54:20 +08:00
|
|
|
ok(verify("ee-ss-with-keyCertSign", "", ["ee-ss-with-keyCertSign"], []),
|
|
|
|
"accept trusted self-signed EE cert with key usage keyCertSign also when strict");
|
2019-12-24 18:25:15 +08:00
|
|
|
|
2017-04-27 01:46:31 +08:00
|
|
|
SKIP: {
|
2020-06-27 22:16:12 +08:00
|
|
|
skip "Ed25519 is not supported by this OpenSSL build", 6
|
2023-04-17 16:20:31 +08:00
|
|
|
if disabled("ecx");
|
2017-04-27 01:46:31 +08:00
|
|
|
|
|
|
|
# ED25519 certificate from draft-ietf-curdle-pkix-04
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-ed25519", "", ["root-ed25519"], []),
|
2019-12-23 22:40:47 +08:00
|
|
|
"accept X25519 EE cert issued by trusted Ed25519 self-signed CA cert");
|
2017-04-27 01:46:31 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-ed25519", "", ["root-ed25519"], [], "-x509_strict"),
|
2020-06-27 22:16:12 +08:00
|
|
|
"reject X25519 EE cert in strict mode since AKID is missing");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("root-ed25519", "", ["ee-ed25519"], []),
|
2019-12-24 03:23:24 +08:00
|
|
|
"fail Ed25519 CA and EE certs swapped");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("root-ed25519", "", ["root-ed25519"], []),
|
2019-12-24 03:23:24 +08:00
|
|
|
"accept trusted Ed25519 self-signed CA cert");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(!verify("ee-ed25519", "", ["ee-ed25519"], []),
|
2019-12-24 03:23:24 +08:00
|
|
|
"fail trusted Ed25519-signed self-issued X25519 cert");
|
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok(verify("ee-ed25519", "", ["ee-ed25519"], [], "-partial_chain"),
|
2019-12-24 03:23:24 +08:00
|
|
|
"accept last-resort direct leaf match Ed25519-signed self-issued cert");
|
|
|
|
|
2017-04-27 01:46:31 +08:00
|
|
|
}
|
2019-03-13 16:54:11 +08:00
|
|
|
|
|
|
|
SKIP: {
|
2021-03-02 20:20:38 +08:00
|
|
|
skip "SM2 is not supported by this OpenSSL build", 2 if disabled("sm2");
|
2019-03-13 16:54:11 +08:00
|
|
|
|
2021-03-02 20:20:38 +08:00
|
|
|
ok_nofips(verify("sm2", "", ["sm2-ca-cert"], [], "-vfyopt", "distid:1234567812345678"),
|
2019-03-13 16:54:11 +08:00
|
|
|
"SM2 ID test");
|
2021-03-02 20:20:38 +08:00
|
|
|
ok_nofips(verify("sm2", "", ["sm2-ca-cert"], [], "-vfyopt", "hexdistid:31323334353637383132333435363738"),
|
2019-03-13 16:54:11 +08:00
|
|
|
"SM2 hex ID test");
|
|
|
|
}
|
2021-09-03 21:00:47 +08:00
|
|
|
|
|
|
|
# Mixed content tests
|
|
|
|
my $cert_file = srctop_file('test', 'certs', 'root-cert.pem');
|
|
|
|
my $rsa_file = srctop_file('test', 'certs', 'key-pass-12345.pem');
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
my $certplusrsa_file = 'certplusrsa.pem';
|
|
|
|
my $certplusrsa;
|
|
|
|
|
|
|
|
skip "Couldn't create certplusrsa.pem", 1
|
|
|
|
unless ( open $certplusrsa, '>', $certplusrsa_file
|
|
|
|
and copy($cert_file, $certplusrsa)
|
2021-09-07 03:49:34 +08:00
|
|
|
and copy($rsa_file, $certplusrsa)
|
|
|
|
and close $certplusrsa );
|
2021-09-03 21:00:47 +08:00
|
|
|
|
|
|
|
ok(run(app([ qw(openssl verify -trusted), $certplusrsa_file, $cert_file ])),
|
|
|
|
'Mixed cert + key file test');
|
|
|
|
}
|
|
|
|
|
|
|
|
SKIP: {
|
|
|
|
my $rsapluscert_file = 'rsapluscert.pem';
|
|
|
|
my $rsapluscert;
|
|
|
|
|
|
|
|
skip "Couldn't create rsapluscert.pem", 1
|
|
|
|
unless ( open $rsapluscert, '>', $rsapluscert_file
|
|
|
|
and copy($rsa_file, $rsapluscert)
|
2021-09-07 03:49:34 +08:00
|
|
|
and copy($cert_file, $rsapluscert)
|
|
|
|
and close $rsapluscert );
|
2021-09-03 21:00:47 +08:00
|
|
|
|
|
|
|
ok(run(app([ qw(openssl verify -trusted), $rsapluscert_file, $cert_file ])),
|
|
|
|
'Mixed key + cert file test');
|
|
|
|
}
|
2023-03-08 01:07:57 +08:00
|
|
|
|
|
|
|
# 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");
|