]> git.ipfire.org Git - thirdparty/FORT-validator.git/commit
Ensure X509 extensions are hashed & cached, before deciding a cert is CA or EE 88/head
authorJob Snijders <job@sobornost.net>
Sat, 21 Jan 2023 11:43:02 +0000 (11:43 +0000)
committerJob Snijders <job@sobornost.net>
Sat, 21 Jan 2023 11:43:02 +0000 (11:43 +0000)
commit178cbd77eac28e5442be5c9134107714f0243ca2
tree9f4cbda29277ac746c6562e2680aaf154a9d428e
parent31ddde6716281f4a8d47b46a764f84e6a1e7271e
Ensure X509 extensions are hashed & cached, before deciding a cert is CA or EE

If X509_check_ca() fails to cache X509v3 extension values, the return
value may be incorrect, leading to erroneously assuming a given certificate
is a CA or EE cert (while in reality it is the other, or neither).

This failure mode can arise because X509_check_ca() doesn't verify
whether libcrypto's (void)x509v3_cache_extensions(x) flipped the EXFLAG_INVALID
flag in x->ex_flags. Unfortunately, X509_check_ca() doesn't have a return code
to indicate an error, so this can't be fixed in libcrypto - the API is broken.

The workaround is to call X509_check_purpose(3) with a purpose argument of -1,
before calling X509_check_ca(), this ensures the X509v3 extensions are cached.
Since X509_check_purpose() does have a return code to indicate errors, we can
use that to supplement X509_check_ca()'s shortcomings.

OpenBSD's rpki-client also uses the above approach.
src/object/certificate.c