diff --git a/lib/tls/mbedtls/mbedtls-client.c b/lib/tls/mbedtls/mbedtls-client.c index 8a1b63e61..873632d30 100644 --- a/lib/tls/mbedtls/mbedtls-client.c +++ b/lib/tls/mbedtls/mbedtls-client.c @@ -37,12 +37,15 @@ lws_ssl_client_bio_create(struct lws *wsi) const char *alpn_comma = wsi->context->tls.alpn_default; struct alpn_ctx protos; - if (lws_hdr_copy(wsi, hostname, sizeof(hostname), - _WSI_TOKEN_CLIENT_HOST) <= 0) { - lwsl_err("%s: Unable to get hostname\n", __func__); + if (wsi->stash) + lws_strncpy(hostname, wsi->stash->cis[CIS_HOST], sizeof(hostname)); + else + if (lws_hdr_copy(wsi, hostname, sizeof(hostname), + _WSI_TOKEN_CLIENT_HOST) <= 0) { + lwsl_err("%s: Unable to get hostname\n", __func__); - return -1; - } + return -1; + } /* * remove any :port part on the hostname... necessary for network diff --git a/lib/tls/openssl/openssl-client.c b/lib/tls/openssl/openssl-client.c index ccc1952f6..1cf6a9aa5 100644 --- a/lib/tls/openssl/openssl-client.c +++ b/lib/tls/openssl/openssl-client.c @@ -141,14 +141,18 @@ lws_ssl_client_bio_create(struct lws *wsi) int n; #endif + if (wsi->stash) + lws_strncpy(hostname, wsi->stash->cis[CIS_HOST], sizeof(hostname)); + else { #if defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2) - if (lws_hdr_copy(wsi, hostname, sizeof(hostname), - _WSI_TOKEN_CLIENT_HOST) <= 0) + if (lws_hdr_copy(wsi, hostname, sizeof(hostname), + _WSI_TOKEN_CLIENT_HOST) <= 0) #endif - { - lwsl_err("%s: Unable to get hostname\n", __func__); + { + lwsl_err("%s: Unable to get hostname\n", __func__); - return -1; + return -1; + } } /*