diff options
author | beck <> | 2018-04-06 07:08:20 +0000 |
---|---|---|
committer | beck <> | 2018-04-06 07:08:20 +0000 |
commit | cbd1d6a8808038e6f357e956a343f70ecaf110f4 (patch) | |
tree | 3f536dd9c6701ce8c8c9a5fa0d5c883caa5222e2 /src/lib/libcrypto/x509/x509_vfy.c | |
parent | a0522cf10ae4b806e95c44e85e22fae53f9228d6 (diff) | |
download | openbsd-cbd1d6a8808038e6f357e956a343f70ecaf110f4.tar.gz openbsd-cbd1d6a8808038e6f357e956a343f70ecaf110f4.tar.bz2 openbsd-cbd1d6a8808038e6f357e956a343f70ecaf110f4.zip |
poison for X509_VERIFY_PARAM's
Tighten up checks for various X509_VERIFY_PARAM functions, and
allow for the verify param to be poisoned (preculding future
successful cert validation) if the setting of host, ip, or email
for certificate validation fails. (since many callers do not
check the return code in the wild and blunder along anyway)
Inspired by some discussions with Adam Langley.
ok jsing@
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vfy.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index c8ccae5029..8392f509e7 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_vfy.c,v 1.68 2018/02/22 17:11:30 jsing Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.69 2018/04/06 07:08:20 beck Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -182,10 +182,13 @@ check_id_error(X509_STORE_CTX *ctx, int errcode) | |||
182 | static int | 182 | static int |
183 | check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id) | 183 | check_hosts(X509 *x, X509_VERIFY_PARAM_ID *id) |
184 | { | 184 | { |
185 | size_t i; | 185 | size_t i, n; |
186 | size_t n = sk_OPENSSL_STRING_num(id->hosts); | ||
187 | char *name; | 186 | char *name; |
188 | 187 | ||
188 | if (id->poisoned) | ||
189 | return 0; | ||
190 | |||
191 | n = sk_OPENSSL_STRING_num(id->hosts); | ||
189 | free(id->peername); | 192 | free(id->peername); |
190 | id->peername = NULL; | 193 | id->peername = NULL; |
191 | 194 | ||
@@ -205,6 +208,10 @@ check_id(X509_STORE_CTX *ctx) | |||
205 | X509_VERIFY_PARAM_ID *id = vpm->id; | 208 | X509_VERIFY_PARAM_ID *id = vpm->id; |
206 | X509 *x = ctx->cert; | 209 | X509 *x = ctx->cert; |
207 | 210 | ||
211 | if (id->poisoned) | ||
212 | if (!check_id_error(ctx, X509_V_ERR_INVALID_CALL)) | ||
213 | return 0; | ||
214 | |||
208 | if (id->hosts && check_hosts(x, id) <= 0) { | 215 | if (id->hosts && check_hosts(x, id) <= 0) { |
209 | if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH)) | 216 | if (!check_id_error(ctx, X509_V_ERR_HOSTNAME_MISMATCH)) |
210 | return 0; | 217 | return 0; |