From b10fff2d2486c7f66b4a443e8ad68ef2b2021928 Mon Sep 17 00:00:00 2001 From: beck <> Date: Sun, 13 Nov 2022 18:37:32 +0000 Subject: Check certificate extensions in trusted certificates. Historically the standards let the implementation decide to either check or ignore the certificate properties of trust anchors. You could either use them simply as a source of a public key which was trusted for everything, or you were also permitted to check the certificate properties and fully enforce them. Hooray for freedumb. OpenSSL changed to checking these with : commit 0daccd4dc1f1ac62181738a91714f35472e50f3c Author: Viktor Dukhovni Date: Thu Jan 28 03:01:45 2016 -0500 BoringSSL currently does not check them, as it also inherited the previous OpenSSL behaviour. It will change to check them in the future. (https://bugs.chromium.org/p/boringssl/issues/detail?id=533) --- src/lib/libcrypto/x509/x509_trs.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/x509/x509_trs.c') diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c index a967edf933..23eca4927b 100644 --- a/src/lib/libcrypto/x509/x509_trs.c +++ b/src/lib/libcrypto/x509/x509_trs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_trs.c,v 1.26 2022/11/10 16:52:19 beck Exp $ */ +/* $OpenBSD: x509_trs.c,v 1.27 2022/11/13 18:37:32 beck Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ @@ -110,8 +110,8 @@ int return oldtrust; } -int -X509_check_trust(X509 *x, int id, int flags) +static int +X509_check_trust_internal(X509 *x, int id, int flags, int compat) { X509_TRUST *pt; int idx; @@ -132,7 +132,7 @@ X509_check_trust(X509 *x, int id, int flags) rv = obj_trust(NID_anyExtendedKeyUsage, x, 0); if (rv != X509_TRUST_UNTRUSTED) return rv; - return trust_compat(NULL, x, 0); + return compat && trust_compat(NULL, x, 0); } idx = X509_TRUST_get_by_id(id); if (idx == -1) @@ -141,6 +141,18 @@ X509_check_trust(X509 *x, int id, int flags) return pt->check_trust(pt, x, flags); } +int +X509_check_trust(X509 *x, int id, int flags) +{ + return X509_check_trust_internal(x, id, flags, /*compat =*/1); +} + +int +x509_check_trust_no_compat(X509 *x, int id, int flags) +{ + return X509_check_trust_internal(x, id, flags, /*compat =*/0); +} + int X509_TRUST_get_count(void) { -- cgit v1.2.3-55-g6feb