diff options
Diffstat (limited to 'src/lib/libtls/tls_server.c')
-rw-r--r-- | src/lib/libtls/tls_server.c | 11 |
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 | } |