diff --git a/components/esp-tls/esp_tls.h b/components/esp-tls/esp_tls.h index 1d46b62e74d..ed28cc70ddc 100644 --- a/components/esp-tls/esp_tls.h +++ b/components/esp-tls/esp_tls.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -189,7 +189,14 @@ typedef struct esp_tls_cfg { const char *common_name; /*!< If non-NULL, server certificate CN must match this name. If NULL, server certificate CN must match hostname. */ - bool skip_common_name; /*!< Skip any validation of server certificate CN field */ + bool skip_common_name; /*!< When true, esp-tls skips the call to + mbedtls_ssl_set_hostname(). This disables BOTH + server-hostname matching against the certificate + (CN/SAN) and Server Name Indication (SNI), not just + the legacy CN field. Only set on loopback / debug + clients that can tolerate the loss of hostname + authentication. Must be false for SNI to function + correctly. */ tls_keep_alive_cfg_t *keep_alive_cfg; /*!< Enable TCP keep-alive timeout for SSL connection */ diff --git a/components/esp-tls/esp_tls_mbedtls.c b/components/esp-tls/esp_tls_mbedtls.c index 37a22b5fa42..fdf40f96007 100644 --- a/components/esp-tls/esp_tls_mbedtls.c +++ b/components/esp-tls/esp_tls_mbedtls.c @@ -739,6 +739,9 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t } free(use_host); } else { + ESP_LOGW(TAG, "skip_common_name=true: hostname matching and SNI disabled. " + "This disables ALL server-name authentication (CN/SAN/SNI), not just CN. " + "Only intended for loopback / debug clients."); mbedtls_ssl_set_hostname(&tls->ssl, NULL); } @@ -813,10 +816,6 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t #else ESP_LOGE(TAG, "psk_hint_key configured but not enabled in menuconfig: Please enable ESP_TLS_PSK_VERIFICATION option"); return ESP_ERR_INVALID_STATE; -#endif -#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS - } else if (cfg->client_session != NULL) { - ESP_LOGD(TAG, "Resuing the saved client session"); #endif } else { #ifdef CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY