Skip to content

Commit 7801d11

Browse files
committed
fix(esp_tls): PSK available in headers only if enabled in Kconfig
1 parent 7ef2379 commit 7801d11

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

components/esp-tls/esp_tls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ typedef struct esp_tls_cfg {
187187

188188
tls_keep_alive_cfg_t *keep_alive_cfg; /*!< Enable TCP keep-alive timeout for SSL connection */
189189

190+
#if defined(CONFIG_ESP_TLS_PSK_VERIFICATION)
190191
const psk_hint_key_t* psk_hint_key; /*!< Pointer to PSK hint and key. if not NULL (and certificates are NULL)
191192
then PSK authentication is enabled with configured setup.
192193
Important note: the pointer must be valid for connection */
194+
#endif /* CONFIG_ESP_TLS_PSK_VERIFICATION */
193195

194196
esp_err_t (*crt_bundle_attach)(void *conf);
195197
/*!< Function pointer to esp_crt_bundle_attach. Enables the use of certification

components/esp-tls/esp_tls_mbedtls.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,8 +782,8 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t
782782
return esp_ret;
783783
}
784784
mbedtls_ssl_conf_ca_chain(&tls->conf, tls->cacert_ptr, NULL);
785-
} else if (cfg->psk_hint_key) {
786785
#if defined(CONFIG_ESP_TLS_PSK_VERIFICATION)
786+
} else if (cfg->psk_hint_key) {
787787
//
788788
// PSK encryption mode is configured only if no certificate supplied and psk pointer not null
789789
ESP_LOGD(TAG, "ssl psk authentication");
@@ -795,13 +795,10 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t
795795
ESP_INT_EVENT_TRACKER_CAPTURE(tls->error_handle, ESP_TLS_ERR_TYPE_MBEDTLS, -ret);
796796
return ESP_ERR_MBEDTLS_SSL_CONF_PSK_FAILED;
797797
}
798-
#else
799-
ESP_LOGE(TAG, "psk_hint_key configured but not enabled in menuconfig: Please enable ESP_TLS_PSK_VERIFICATION option");
800-
return ESP_ERR_INVALID_STATE;
801798
#endif
802799
#ifdef CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS
803800
} else if (cfg->client_session != NULL) {
804-
ESP_LOGD(TAG, "Resuming the saved client session");
801+
ESP_LOGD(TAG, "Reusing the saved client session");
805802
#endif
806803
} else {
807804
#ifdef CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY

0 commit comments

Comments
 (0)