From 945aa4df0c1c96c8f84972c185da9a86203c4348 Mon Sep 17 00:00:00 2001 From: lyzsuper Date: Wed, 16 Dec 2020 11:00:59 +0800 Subject: [PATCH] update wifi_start_ssl_client api for fix ssl connect problem --- src/wifi/wifi_ssl_client.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wifi/wifi_ssl_client.c b/src/wifi/wifi_ssl_client.c index 7936d7a..c922719 100644 --- a/src/wifi/wifi_ssl_client.c +++ b/src/wifi/wifi_ssl_client.c @@ -426,11 +426,6 @@ int wifi_start_ssl_client(wifi_sslclient_context *ssl_client, const char *host, //log_v("Setting hostname :%s for TLS session...", host); - // // Hostname set here should match CN in server certificate - // if ((ret = mbedtls_ssl_set_hostname(&ssl_client->ssl_ctx, host)) != 0) - // { - // return handle_error(ret); - // } if ((ret = mbedtls_ssl_setup(&ssl_client->ssl_ctx, &ssl_client->ssl_conf)) != 0) { @@ -439,6 +434,13 @@ int wifi_start_ssl_client(wifi_sslclient_context *ssl_client, const char *host, mbedtls_ssl_set_bio(&ssl_client->ssl_ctx, &ssl_client->socket, mbedtls_net_send, mbedtls_net_recv, NULL); + // Hostname set here should match CN in server certificate + if ((ret = mbedtls_ssl_set_hostname(&ssl_client->ssl_ctx, host)) != 0) + { + printf("wifi_start_ssl_client mbedtls_ssl_set_hostname failed \r\n"); + return handle_error(ret); + } + log_v("Performing the SSL/TLS handshake..."); unsigned long handshake_start_time = millis(); while ((ret = mbedtls_ssl_handshake(&ssl_client->ssl_ctx)) != 0)