Add esp_tls option to skip server verification

This commit is contained in:
2022-06-13 17:34:00 +02:00
parent dffabb067f
commit 7e19495fb0
3 changed files with 5 additions and 0 deletions

View File

@ -259,6 +259,7 @@ typedef struct esp_mqtt_client_config_t {
verify broker.*/
bool skip_cert_common_name_check; /*!< Skip any validation of server certificate CN field, this reduces the
security of TLS and makes the *MQTT* client susceptible to MITM attacks */
bool skip_server_verification; /*!< Skip server verification completely. Should only be used for debugging */
const char **alpn_protos; /*!< NULL-terminated list of supported application protocols to be used for ALPN */
} verification; /*!< Security verification of the broker */
} broker; /*!< Broker address and security verification */

View File

@ -89,6 +89,7 @@ typedef struct {
size_t clientkey_bytes;
const struct psk_key_hint *psk_hint_key;
bool skip_cert_common_name_check;
bool skip_server_verification;
bool use_secure_element;
void *ds_data;
int message_retransmit_timeout;

View File

@ -126,6 +126,8 @@ static esp_err_t esp_mqtt_set_ssl_transport_properties(esp_transport_list_handle
if (cfg->use_global_ca_store == true) {
esp_transport_ssl_enable_global_ca_store(ssl);
} else if (cfg->skip_server_verification == true) {
esp_transport_ssl_skip_server_verification(ssl);
} else if (cfg->crt_bundle_attach != NULL) {
#ifdef MQTT_SUPPORTED_FEATURE_CERTIFICATE_BUNDLE
#ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE
@ -509,6 +511,7 @@ esp_err_t esp_mqtt_set_config(esp_mqtt_client_handle_t client, const esp_mqtt_cl
client->config->clientkey_buf = config->credentials.authentication.key;
client->config->clientkey_bytes = config->credentials.authentication.key_len;
client->config->skip_cert_common_name_check = config->broker.verification.skip_cert_common_name_check;
client->config->skip_server_verification = config->broker.verification.skip_server_verification;
client->config->use_secure_element = config->credentials.authentication.use_secure_element;
client->config->ds_data = config->credentials.authentication.ds_data;