summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2022-05-10 19:42:52 +0000
committertb <>2022-05-10 19:42:52 +0000
commit60292e3c622f4c29a5af160d34b90580ef8c6d03 (patch)
tree60fe30f710c955610cc67d15f8ffd93470272bb4
parent87bc747a621099ecbcaca15ffcd7fce26af82d67 (diff)
downloadopenbsd-60292e3c622f4c29a5af160d34b90580ef8c6d03.tar.gz
openbsd-60292e3c622f4c29a5af160d34b90580ef8c6d03.tar.bz2
openbsd-60292e3c622f4c29a5af160d34b90580ef8c6d03.zip
X509_check_ca() has 5 return values but still can't fail
The values 0, 1, 3, 4, 5 all have some meaning, none of which is failure. If caching of X509v3 extensions fails, returning X509_V_ERR_UNSPECIFIED, i.e., 1 is a bad idea since that means the cert is a CA with appropriate basic constraints. Revert to OpenSSL behavior which is to ignore failure to cache extensions at the risk of reporting lies. Since no return value can indicate failure, we can't fix this in X509_check_ca() itself. Application code will have to call (and check) the magic X509_check_purpose(x, -1, -1) to ensure extensions are cached, then X509_check_ca() can't lie. ok jsing
-rw-r--r--src/lib/libcrypto/x509/x509_purp.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_purp.c b/src/lib/libcrypto/x509/x509_purp.c
index ffd986b4a1..ab5e7cb3c9 100644
--- a/src/lib/libcrypto/x509/x509_purp.c
+++ b/src/lib/libcrypto/x509/x509_purp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_purp.c,v 1.15 2022/04/21 04:48:12 tb Exp $ */ 1/* $OpenBSD: x509_purp.c,v 1.16 2022/05/10 19:42:52 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 2001. 3 * project 2001.
4 */ 4 */
@@ -671,8 +671,6 @@ X509_check_ca(X509 *x)
671 CRYPTO_w_lock(CRYPTO_LOCK_X509); 671 CRYPTO_w_lock(CRYPTO_LOCK_X509);
672 x509v3_cache_extensions(x); 672 x509v3_cache_extensions(x);
673 CRYPTO_w_unlock(CRYPTO_LOCK_X509); 673 CRYPTO_w_unlock(CRYPTO_LOCK_X509);
674 if (x->ex_flags & EXFLAG_INVALID)
675 return X509_V_ERR_UNSPECIFIED;
676 } 674 }
677 675
678 return check_ca(x); 676 return check_ca(x);