OPEnSLab-OSU / SSLClient

🔒Add SSL/TLS functionality to any Arduino library
https://openslab-osu.github.io/SSLClient/index.html
GNU General Public License v3.0
155 stars 47 forks source link

Cannot operate on a closed SSL connection #68

Open radu-bethub opened 2 years ago

radu-bethub commented 2 years ago

I'm getting

13:17:55.152 > (SSLClient)(SSL_ERROR)(available): Cannot operate on a closed SSL connection. 13:17:55.152 > (SSLClient)(SSL_ERROR)(m_print_br_error): Incoming record is too large to be processed, or buffer is too small for the handshake message to send.

while trying to get my firmware bin file.

EthernetClient ClientESP; SSLClient clientESP(ClientESP, TAs, (size_t)TAs_NUM, 25); HttpClient clientHttp = HttpClient(clientESP, server, 443);

any idea? my GET server address is hosted on cloudflare.

prototypicalpro commented 2 years ago

This error is likely occurring because SSLClient's internal buffer is too small to fit the entire firmware file. You can try increasing the buffer size by increasing the size of the following array in your copy of SSLClient: https://github.com/OPEnSLab-OSU/SSLClient/blob/1fe48948004a3ad52705ab26db4f65833ecb4e12/src/SSLClient.h#L469 If that doesn't work, you can also try this other SSLClient that dynamically allocates memory and should handle large records better: https://github.com/govorox/SSLClient

radu-bethub commented 2 years ago

well done @prototypicalpro. I managed to increase the buffer directly from library for testing and now the update OTA is working well. I will continue to work in order to don't alter the library directly and increase that variable from my env. thanks a lot for you help.

javierdelavega commented 1 month ago

Hello. I have ran in the same issue (only when using Cloudflare) and your solution worked for me, so thanks @prototypicalpro. @radu-bethub did you managed to increase the buffer size with an env setting? I can't figure out how to do that, since the buffer size seems to be hardcoded in the SSLCLient.h. Am I missing something?