diff options
author | jsing <> | 2017-04-10 17:11:13 +0000 |
---|---|---|
committer | jsing <> | 2017-04-10 17:11:13 +0000 |
commit | 1fb5784eee903ab9b8621581b6128aaccf2d3120 (patch) | |
tree | 2ba4db6e1d15d0e16b83f40c86378539156871c3 /src/lib/libtls/tls_client.c | |
parent | a887f273016c6b1a211de9fd477d86b2b8c26792 (diff) | |
download | openbsd-1fb5784eee903ab9b8621581b6128aaccf2d3120.tar.gz openbsd-1fb5784eee903ab9b8621581b6128aaccf2d3120.tar.bz2 openbsd-1fb5784eee903ab9b8621581b6128aaccf2d3120.zip |
Rework name verification code so that a match is indicated via an argument,
rather than return codes. More strictly follow RFC 6125, in particular only
check the CN if there are no SAN identifiers present in the certificate
(per section 6.4.4).
Previous behaviour questioned by Daniel Stenberg <daniel at haxx dot se>.
ok beck@ jca@
Diffstat (limited to 'src/lib/libtls/tls_client.c')
-rw-r--r-- | src/lib/libtls/tls_client.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/libtls/tls_client.c b/src/lib/libtls/tls_client.c index a1e2caa717..0e519684ef 100644 --- a/src/lib/libtls/tls_client.c +++ b/src/lib/libtls/tls_client.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_client.c,v 1.40 2017/01/26 12:56:37 jsing Exp $ */ | 1 | /* $OpenBSD: tls_client.c,v 1.41 2017/04/10 17:11:13 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -289,7 +289,7 @@ int | |||
289 | tls_handshake_client(struct tls *ctx) | 289 | tls_handshake_client(struct tls *ctx) |
290 | { | 290 | { |
291 | X509 *cert = NULL; | 291 | X509 *cert = NULL; |
292 | int ssl_ret; | 292 | int match, ssl_ret; |
293 | int rv = -1; | 293 | int rv = -1; |
294 | 294 | ||
295 | if ((ctx->flags & TLS_CLIENT) == 0) { | 295 | if ((ctx->flags & TLS_CLIENT) == 0) { |
@@ -311,11 +311,11 @@ tls_handshake_client(struct tls *ctx) | |||
311 | tls_set_errorx(ctx, "no server certificate"); | 311 | tls_set_errorx(ctx, "no server certificate"); |
312 | goto err; | 312 | goto err; |
313 | } | 313 | } |
314 | if ((rv = tls_check_name(ctx, cert, | 314 | if (tls_check_name(ctx, cert, ctx->servername, &match) == -1) |
315 | ctx->servername)) != 0) { | 315 | goto err; |
316 | if (rv != -2) | 316 | if (!match) { |
317 | tls_set_errorx(ctx, "name `%s' not present in" | 317 | tls_set_errorx(ctx, "name `%s' not present in" |
318 | " server certificate", ctx->servername); | 318 | " server certificate", ctx->servername); |
319 | goto err; | 319 | goto err; |
320 | } | 320 | } |
321 | } | 321 | } |