From 43896ebfe02f31349608417aa1eb2e3020e80b08 Mon Sep 17 00:00:00 2001 From: Ivan Golubic Date: Fri, 28 Aug 2020 15:42:14 +0400 Subject: [PATCH 1/2] Fix for https://github.com/espressif/arduino-esp32/issues/3460 issue --- libraries/WiFiClientSecure/src/ssl_client.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index 3fa6138f558..b3899b9f700 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -276,24 +276,18 @@ int data_to_read(sslclient_context *ssl_client) return res; } - int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t len) { - log_v("Writing HTTP request..."); //for low level debug + log_v("Writing HTTP request with %d bytes...", len); //for low level debug int ret = -1; - while ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0) { - if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { - return handle_error(ret); - } - } + if ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0) + return handle_error(ret); - len = ret; - //log_v("%d bytes written", len); //for low level debug + log_v("Returning with %d bytes written", ret); //for low level debug return ret; } - int get_ssl_receive(sslclient_context *ssl_client, uint8_t *data, int length) { //log_d( "Reading HTTP response..."); //for low level debug From 93a945428844eb25c852855f89f4eedd2ec82fe3 Mon Sep 17 00:00:00 2001 From: Ivan Golubic Date: Fri, 28 Aug 2020 16:33:24 +0400 Subject: [PATCH 2/2] Improved logging --- libraries/WiFiClientSecure/src/ssl_client.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index b3899b9f700..668fa72303f 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -281,10 +281,13 @@ int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t l log_v("Writing HTTP request with %d bytes...", len); //for low level debug int ret = -1; - if ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0) + if ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0){ + log_v("Handling error %d", ret); //for low level debug return handle_error(ret); + } else{ + log_v("Returning with %d bytes written", ret); //for low level debug + } - log_v("Returning with %d bytes written", ret); //for low level debug return ret; }