tcp_transport: Fix error handling of esp_tls_init()

This commit is contained in:
David Cermak
2021-03-19 14:51:43 +01:00
committed by bot
parent a560a506f2
commit c7de165ccb

View File

@@ -72,6 +72,10 @@ static int ssl_connect(esp_transport_handle_t t, const char *host, int port, int
ssl->cfg.timeout_ms = timeout_ms; ssl->cfg.timeout_ms = timeout_ms;
ssl->ssl_initialized = true; ssl->ssl_initialized = true;
ssl->tls = esp_tls_init(); ssl->tls = esp_tls_init();
if (ssl->tls == NULL) {
ESP_LOGE(TAG, "Failed to initialize new connection object");
return -1;
}
if (esp_tls_conn_new_sync(host, strlen(host), port, &ssl->cfg, ssl->tls) <= 0) { if (esp_tls_conn_new_sync(host, strlen(host), port, &ssl->cfg, ssl->tls) <= 0) {
ESP_LOGE(TAG, "Failed to open a new connection"); ESP_LOGE(TAG, "Failed to open a new connection");
esp_transport_set_errors(t, ssl->tls->error_handle); esp_transport_set_errors(t, ssl->tls->error_handle);