diff options
author | jca <> | 2014-10-06 11:55:48 +0000 |
---|---|---|
committer | jca <> | 2014-10-06 11:55:48 +0000 |
commit | 9f002a02695c03cc68e80c6df9e37bca5b58ecfa (patch) | |
tree | 7f694aef6c3ebf36a2ce0b7e23b5d023d1d701c8 /src | |
parent | d2eb62ff43d96ad0684a0683817df2b84e342097 (diff) | |
download | openbsd-9f002a02695c03cc68e80c6df9e37bca5b58ecfa.tar.gz openbsd-9f002a02695c03cc68e80c6df9e37bca5b58ecfa.tar.bz2 openbsd-9f002a02695c03cc68e80c6df9e37bca5b58ecfa.zip |
When verifying whether an IP address is in the commonName of a
certificate, do not perform wildcard matching.
Suggested by Richard Moore (rich@kde)
ok tedu@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libressl/ressl_verify.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/libressl/ressl_verify.c b/src/lib/libressl/ressl_verify.c index 9511ad2ff2..5e9f370e1c 100644 --- a/src/lib/libressl/ressl_verify.c +++ b/src/lib/libressl/ressl_verify.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ressl_verify.c,v 1.4 2014/10/06 11:53:18 jca Exp $ */ | 1 | /* $OpenBSD: ressl_verify.c,v 1.5 2014/10/06 11:55:48 jca Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> | 3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> |
4 | * | 4 | * |
@@ -166,6 +166,7 @@ ressl_check_common_name(X509 *cert, const char *host) | |||
166 | char *common_name = NULL; | 166 | char *common_name = NULL; |
167 | int common_name_len; | 167 | int common_name_len; |
168 | int rv = -1; | 168 | int rv = -1; |
169 | union { struct in_addr ip4; struct in6_addr ip6; } addrbuf; | ||
169 | 170 | ||
170 | name = X509_get_subject_name(cert); | 171 | name = X509_get_subject_name(cert); |
171 | if (name == NULL) | 172 | if (name == NULL) |
@@ -191,6 +192,19 @@ ressl_check_common_name(X509 *cert, const char *host) | |||
191 | goto out; | 192 | goto out; |
192 | } | 193 | } |
193 | 194 | ||
195 | if (inet_pton(AF_INET, host, &addrbuf) == 1 || | ||
196 | inet_pton(AF_INET6, host, &addrbuf) == 1) { | ||
197 | /* | ||
198 | * We don't want to attempt wildcard matching against IP | ||
199 | * addresses, so perform a simple comparison here. | ||
200 | */ | ||
201 | if (strcmp(common_name, host) == 0) | ||
202 | rv = 0; | ||
203 | else | ||
204 | rv = -1; | ||
205 | goto out; | ||
206 | } | ||
207 | |||
194 | if (ressl_match_hostname(common_name, host) == 0) | 208 | if (ressl_match_hostname(common_name, host) == 0) |
195 | rv = 0; | 209 | rv = 0; |
196 | out: | 210 | out: |