summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-01-22 23:52:06 +0100
committerDaniel Stenberg <daniel@haxx.se>2022-01-23 11:59:54 +0100
commitd874adea4a5ef25446a09c01b5c3aaaf9be995c9 (patch)
tree3bf4dd8aa56e0e74ae8bb7d2b33cada0597c14e2
parentd42a72a64c1a411a8ca34900c642835ef8b6f9fb (diff)
downloadcurl-d874adea4a5ef25446a09c01b5c3aaaf9be995c9.tar.gz
gnutls: set the right SNI name
-rw-r--r--lib/vtls/gtls.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
index 18864aa4b..f9ef4d12b 100644
--- a/lib/vtls/gtls.c
+++ b/lib/vtls/gtls.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -542,11 +542,15 @@ gtls_connect_step1(struct Curl_easy *data,
#ifdef ENABLE_IPV6
(0 == Curl_inet_pton(AF_INET6, hostname, &addr)) &&
#endif
- sni &&
- (gnutls_server_name_set(session, GNUTLS_NAME_DNS, hostname,
- strlen(hostname)) < 0))
- infof(data, "WARNING: failed to configure server name indication (SNI) "
- "TLS extension");
+ sni) {
+ size_t snilen;
+ char *snihost = Curl_ssl_snihost(data, hostname, &snilen);
+ if(!snihost || gnutls_server_name_set(session, GNUTLS_NAME_DNS, snihost,
+ snilen) < 0) {
+ failf(data, "Failed to set SNI");
+ return CURLE_SSL_CONNECT_ERROR;
+ }
+ }
/* Use default priorities */
rc = gnutls_set_default_priority(session);