summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls_client.c
diff options
context:
space:
mode:
authorjsing <>2017-04-10 17:11:13 +0000
committerjsing <>2017-04-10 17:11:13 +0000
commit2c72bbf2735f97ac7b152b55787c620ee18ae10f (patch)
tree2ba4db6e1d15d0e16b83f40c86378539156871c3 /src/lib/libtls/tls_client.c
parentb09404bb3f219fdc5b6964aa84058a927700deb8 (diff)
downloadopenbsd-2c72bbf2735f97ac7b152b55787c620ee18ae10f.tar.gz
openbsd-2c72bbf2735f97ac7b152b55787c620ee18ae10f.tar.bz2
openbsd-2c72bbf2735f97ac7b152b55787c620ee18ae10f.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.c14
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
289tls_handshake_client(struct tls *ctx) 289tls_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 }