From 6ed3d8a9dd68bb1d762a08312dfe4a65aed80922 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 20 Nov 2019 10:24:48 +0000 Subject: [PATCH] client: also allow stashed host param for client tls Client connection items for protocols other than http ones will never get into an ah. Allow use of the values from the client stash allocation instead if present. --- lib/tls/mbedtls/mbedtls-client.c | 13 ++++++++----- lib/tls/openssl/openssl-client.c | 14 +++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) 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; + } } /*