Skip to content

Commit c2eb86b

Browse files
committed
Merge branch 'feature/change_esp_tls_default_behaviour' into 'master'
esp-tls: Changed default behaviour for esp-tls client ( for security purpose) See merge request sdk/ESP8266_RTOS_SDK!1601
2 parents 870aa0a + 7b92080 commit c2eb86b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

components/esp-tls/Kconfig

+19
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ menu "ESP-TLS"
3131
Enable support for pre shared key ciphers, supported for both mbedTLS as well as
3232
wolfSSL TLS library.
3333

34+
config ESP_TLS_INSECURE
35+
bool "Allow potentially insecure options"
36+
help
37+
You can enable some potentially insecure options. These options should only be used for testing pusposes.
38+
Only enable these options if you are very sure.
39+
40+
config ESP_TLS_SKIP_SERVER_CERT_VERIFY
41+
bool "Skip server certificate verification by default (WARNING: ONLY FOR TESTING PURPOSE, READ HELP)"
42+
depends on ESP_TLS_INSECURE
43+
help
44+
After enabling this option the esp-tls client will skip the server certificate verification
45+
by default. Note that this option will only modify the default behaviour of esp-tls client
46+
regarding server cert verification. The default behaviour should only be applicable when
47+
no other option regarding the server cert verification is opted in the esp-tls config
48+
(e.g. crt_bundle_attach, use_global_ca_store etc.).
49+
WARNING : Enabling this option comes with a potential risk of establishing a TLS connection
50+
with a server which has a fake identity, provided that the server certificate
51+
is not provided either through API or other mechanism like ca_store etc.
52+
3453
config ESP_WOLFSSL_SMALL_CERT_VERIFY
3554
bool "Enable SMALL_CERT_VERIFY"
3655
depends on ESP_TLS_USING_WOLFSSL

components/esp-tls/esp_tls_mbedtls.c

+5
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,12 @@ esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls_cfg_t
445445
return ESP_ERR_INVALID_STATE;
446446
#endif
447447
} else {
448+
#ifdef CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY
448449
mbedtls_ssl_conf_authmode(&tls->conf, MBEDTLS_SSL_VERIFY_NONE);
450+
#else
451+
ESP_LOGE(TAG, "No server verification option set in esp_tls_cfg_t structure. Check esp_tls API reference");
452+
return ESP_ERR_MBEDTLS_SSL_SETUP_FAILED;
453+
#endif
449454
}
450455

451456
if (cfg->clientcert_buf != NULL && cfg->clientkey_buf != NULL) {

components/esp-tls/esp_tls_wolfssl.c

+5
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ static esp_err_t set_client_config(const char *hostname, size_t hostlen, esp_tls
201201
return ESP_ERR_INVALID_STATE;
202202
#endif
203203
} else {
204+
#ifdef CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY
204205
wolfSSL_CTX_set_verify( (WOLFSSL_CTX *)tls->priv_ctx, WOLFSSL_VERIFY_NONE, NULL);
206+
#else
207+
ESP_LOGE(TAG, "No server verification option set in esp_tls_cfg_t structure. Check esp_tls API reference");
208+
return ESP_ERR_WOLFSSL_SSL_SETUP_FAILED;
209+
#endif
205210
}
206211

207212
if (cfg->clientcert_buf != NULL && cfg->clientkey_buf != NULL) {

0 commit comments

Comments
 (0)