mobizt / ESP_SSLClient

The upgradable Secure Layer Networking (SSL/TLS) TCP Client for Arduino devices that support external networking interfaces e.g., WiFiClient, EthernetClient, and GSMClient.
MIT License
18 stars 2 forks source link

Data loss #4

Closed DriekdeGadgetfreak closed 7 months ago

DriekdeGadgetfreak commented 7 months ago

As a test I replaced:

WiFiClientSecure client; client.setInsecure();

by

ESP_SSLClient client; WifiClient net; client.setInsecure(); client.setClient(&net);

I connect to a website which returns 7712 (= content-length) bytes with the original code. The replaced code gives a read timeout after 6703 bytes, with the same content-length in the return header. Do I do something wrong?

Regards, Hans

mobizt commented 7 months ago

If you read the Readme, you have to set the BearSSL IO reserve memory size that large enough for the SSL data especially Rx buffer size.

// Set the receive and transmit buffers size in bytes for memory allocation (512 to 16384). // For server that does not support SSL fragment size negotiation, leave this setting the default value // by not set any buffer size or set the rx buffer size to maximum SSL record size (16384) and 512 for tx buffer size.
ssl_client.setBufferSizes(1024 / rx /, 512 / tx /);

You can set it up to 16k for full SSL data frame.

mobizt commented 7 months ago

If you use ESP32, there is a bug in ESP32 WiFiClient that does not work correctly when using as client.

You can use this class instead of WiFiClient in ESP32. https://gist.github.com/mobizt/6c229ba7413f9837059ace31d2e7e8b1

DriekdeGadgetfreak commented 7 months ago

Thanx! That helps me.