diff options
author | tb <> | 2024-03-25 00:46:57 +0000 |
---|---|---|
committer | tb <> | 2024-03-25 00:46:57 +0000 |
commit | 186b5fced9756283591facb6be815bffee027f63 (patch) | |
tree | fb50b2b0f6a4b8d5accea084f6cdece3999193d1 | |
parent | c905c9c1a02b42e85ee10cb846c51abc6595a386 (diff) | |
download | openbsd-186b5fced9756283591facb6be815bffee027f63.tar.gz openbsd-186b5fced9756283591facb6be815bffee027f63.tar.bz2 openbsd-186b5fced9756283591facb6be815bffee027f63.zip |
Pull extension caching into X509_check_trust()
This way the trust handlers can stop modifying the certificates.
ok beck
-rw-r--r-- | src/lib/libcrypto/x509/x509_trs.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libcrypto/x509/x509_trs.c b/src/lib/libcrypto/x509/x509_trs.c index 67576b6a70..72238761c8 100644 --- a/src/lib/libcrypto/x509/x509_trs.c +++ b/src/lib/libcrypto/x509/x509_trs.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_trs.c,v 1.48 2024/03/24 08:27:35 tb Exp $ */ | 1 | /* $OpenBSD: x509_trs.c,v 1.49 2024/03/25 00:46:57 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 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -65,6 +65,7 @@ | |||
65 | #include <openssl/x509v3.h> | 65 | #include <openssl/x509v3.h> |
66 | 66 | ||
67 | #include "crypto_internal.h" | 67 | #include "crypto_internal.h" |
68 | #include "x509_internal.h" | ||
68 | #include "x509_local.h" | 69 | #include "x509_local.h" |
69 | 70 | ||
70 | typedef struct x509_trust_st { | 71 | typedef struct x509_trust_st { |
@@ -103,7 +104,7 @@ obj_trust(int id, X509 *x) | |||
103 | static int | 104 | static int |
104 | trust_compat(X509_TRUST *trust, X509 *x) | 105 | trust_compat(X509_TRUST *trust, X509 *x) |
105 | { | 106 | { |
106 | X509_check_purpose(x, -1, 0); | 107 | /* Extensions already cached in X509_check_trust(). */ |
107 | if (x->ex_flags & EXFLAG_SS) | 108 | if (x->ex_flags & EXFLAG_SS) |
108 | return X509_TRUST_TRUSTED; | 109 | return X509_TRUST_TRUSTED; |
109 | else | 110 | else |
@@ -189,6 +190,10 @@ X509_check_trust(X509 *x, int trust_id, int flags) | |||
189 | if (trust_id == -1) | 190 | if (trust_id == -1) |
190 | return 1; | 191 | return 1; |
191 | 192 | ||
193 | /* Call early so the trust handlers don't need to modify the certs. */ | ||
194 | if (!x509v3_cache_extensions(x)) | ||
195 | return X509_TRUST_UNTRUSTED; | ||
196 | |||
192 | /* | 197 | /* |
193 | * XXX beck/jsing This enables self signed certs to be trusted for | 198 | * XXX beck/jsing This enables self signed certs to be trusted for |
194 | * an unspecified id/trust flag value (this is NOT the | 199 | * an unspecified id/trust flag value (this is NOT the |