summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls_server.c
diff options
context:
space:
mode:
authorjsing <>2017-04-10 17:11:13 +0000
committerjsing <>2017-04-10 17:11:13 +0000
commit1fb5784eee903ab9b8621581b6128aaccf2d3120 (patch)
tree2ba4db6e1d15d0e16b83f40c86378539156871c3 /src/lib/libtls/tls_server.c
parenta887f273016c6b1a211de9fd477d86b2b8c26792 (diff)
downloadopenbsd-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_server.c')
-rw-r--r--src/lib/libtls/tls_server.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/libtls/tls_server.c b/src/lib/libtls/tls_server.c
index 51deff2510..39c6ca79e9 100644
--- a/src/lib/libtls/tls_server.c
+++ b/src/lib/libtls/tls_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_server.c,v 1.35 2017/01/31 15:57:43 jsing Exp $ */ 1/* $OpenBSD: tls_server.c,v 1.36 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 *
@@ -75,11 +75,13 @@ tls_servername_cb(SSL *ssl, int *al, void *arg)
75 union tls_addr addrbuf; 75 union tls_addr addrbuf;
76 struct tls *conn_ctx; 76 struct tls *conn_ctx;
77 const char *name; 77 const char *name;
78 int match;
78 79
79 if ((conn_ctx = SSL_get_app_data(ssl)) == NULL) 80 if ((conn_ctx = SSL_get_app_data(ssl)) == NULL)
80 goto err; 81 goto err;
81 82
82 if ((name = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name)) == NULL) { 83 if ((name = SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name)) ==
84 NULL) {
83 /* 85 /*
84 * The servername callback gets called even when there is no 86 * The servername callback gets called even when there is no
85 * TLS servername extension provided by the client. Sigh! 87 * TLS servername extension provided by the client. Sigh!
@@ -98,7 +100,10 @@ tls_servername_cb(SSL *ssl, int *al, void *arg)
98 100
99 /* Find appropriate SSL context for requested servername. */ 101 /* Find appropriate SSL context for requested servername. */
100 for (sni_ctx = ctx->sni_ctx; sni_ctx != NULL; sni_ctx = sni_ctx->next) { 102 for (sni_ctx = ctx->sni_ctx; sni_ctx != NULL; sni_ctx = sni_ctx->next) {
101 if (tls_check_name(ctx, sni_ctx->ssl_cert, name) == 0) { 103 if (tls_check_name(ctx, sni_ctx->ssl_cert, name,
104 &match) == -1)
105 goto err;
106 if (match) {
102 SSL_set_SSL_CTX(conn_ctx->ssl_conn, sni_ctx->ssl_ctx); 107 SSL_set_SSL_CTX(conn_ctx->ssl_conn, sni_ctx->ssl_ctx);
103 return (SSL_TLSEXT_ERR_OK); 108 return (SSL_TLSEXT_ERR_OK);
104 } 109 }