-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Large download fails with WiFiClientSecure and maybe WiFiClient #4814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Issue template has been completely ignored. Also, the requirement is for a MCVE sketch, which should be included in the issue, and not linked. Emphasis on the M (minimal), the linked sketches are rather big. |
|
With debug activated,
-14 is lwIP's "Connection reset", meaning that the server has closed the TCP session. I tried with another https server of mine and the same file: So this is an interesting problem with TCP, not specifically with ssl. Thanks for the MCVE |
I forgot to enable SSL messages. |
Thank you, I had a hard time to find the WiFiClientSecure example (originally, and again), until I got the idea to search for https in the examples. That said means I am a newbie user of SSL in a program, and don't know about BearSSL. Is there an example somewhere? |
Sure, in
However, the I will try and dig that out, maybe @earlephilhower can help with that precise example. |
Aha. I see these examples on GitHub, but not in my installation. So I need to update. But Boards Manager says 2.4.1 installed... |
You need to install the git version,
2.4.2 is not released yet.
|
@d-a-v thank you, I will try to use it. I need to find out if it is enough to download the actual ESP8266WIFI library. And I can only use it in my library after 2.4.2 is released. Do you think the issue in axTLS will be resolved? Thank you. |
Issues traced to axtls won't be fixed. The bearssl integration is meant to replace axtls. Right now, axtls is still the default, and will remain so as long as bearssl is considered experimental, but axtls will be deprecated and then retired. |
This suggests that the |
Yes, an update is needed. |
@d-a-v @devyte Could you help for me for setting up a post request? String postData = "grant_type=refresh_token&refresh_token=" + currentRefreshToken + "&client_id=" + clientId + "&client_secret=" + clientSecret; client.print(String("POST ") + url + " HTTP/1.1\r\n" + How can I get the json Response from the service? Is there any documentation for this? |
I got confused, as I just set up the ESP8266 package on a new notebook. I now see examples for BearSSL. I then noticed these are also on an other notebook I had updated some time ago. So maybe I was just not aware that BearSSL was already part of the official package for some time. But the example I started with - HTTPSRequest - is still the old one. The link from @d-a-v points to a newer version in his fork. So it looks like I can use BearSSL::WiFiClientSecure, and just need to add client.setFingerprint(fingerprint); to make it work. |
client.setFingerprint((uint8_t*)fingerprint); // ("present the other hand, please") |
This is what I get from BearSSL_Validation Connecting to C4A2760E If there are no CAs or insecure options specified, BearSSL will not connect. This is absolutely insecure, but you can tell BearSSL not to check the HTTP/1.1 200 OK The SHA-1 fingerprint of an X.509 certificate can be used to validate it HTTP/1.1 200 OK It is also possible to accept any self-signed certificate. This is Now we'll enable self-signed certs (will pass) The server certificate can be completely ignored and its public key A specific certification authority can be passed in and used to validate Try again after setting NTP time (should pass) |
aha, not only signed/unsigned difference, but also format: byte array instead of ascii HEX representation, maybe. |
This helps to connect, but the original issue got even worse. |
@ZinggJM With latest master, large downloads with HTTPS are still failing ? |
Boards Manager says "esp8266 by ESP8266 Community version 2.4.2 installed" Yes, large downloads with HTTPS are still failing with BearSSL, and "large" is much smaller than with axTLS. This is the only debug output I see when I enable Debug port and Debug level SSL+TLS_MEM+HTTP_Client SDK:2⸮1 connected with C4A2760E, channel 1 downloading file "logo200x200.bmp" headers received |
Debug output with all enabled. |
How did you achieve this? |
Now I tried the example: BearSSL_MaxFragmentLength.ino
it looks like
does not work. |
I also tried BearSSL_MaxFragmentLength.ino with client.setFingerprint(fp); |
@ZinggJM You also need to work with latest git core. |
Yes, out of memory seems to be the cause with my test, although I had 32292 bytes for local variables, as reported. This example has a 15k graphics buffer for an e-paper display. In the meantime I found out that the GxEPD2_32_Spiffs_Loader works with BearSSL. Maybe the "trick" with the separate stack space just needs too much RAM to be practical. |
I tried to update my MCVE sketch to use with BearSSL to show the issue. But my MCVE sketch works. |
Using BearSSL with GxEPD2_32_Spiffs_Loader resolves the large download issue for this example, and thus for this issue. |
I had used this method (from class Client): |
read() works for me but seems like the response does not match with the one I get from Postman. I have posted the issue here https://www.esp32.com/viewtopic.php?f=19&t=20565&p=75332#p75332. I'm still looking for a solution. Thanks for your help. |
I could successfully download bitmap files up to ~86kB size through WiFiClientSecure, but download of larger files do not terminate. If client.read(buffer, amount) returns zero, every next call does the same forever, although client.connected() still returns true. I tried workaround with client.available() and delay(), but found no safe method. The amount that works seems dependent on available heap size.
example: https://github.com./ZinggJM/GxEPD2_32/tree/master/examples/GxEPD2_32_Spiffs_Loader
The text was updated successfully, but these errors were encountered: