-
Notifications
You must be signed in to change notification settings - Fork 13.3k
OTA update with HTTPS is not working #4400
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
Same behaviour here. I've tried all the overloaded forms of ESPhttpUpdate.update and they all fail in various ways. The sketch below will:
Sketch
Debug output:
|
I have a same problem.... Anyone solve this?? |
Is this the same as #3908 or #4501? One has to do with an out of memory error during HTTPS update (3908), while the other has found a problem in axTLS where the SSL handshake is expecting that each message is sent in a separate TCP packet but some servers pack multiple SSL handshake messages into a single fragment (4501). Can you connect to the specified HTTPS sites using a simple WiFiClientSecure::connect? If not then I'd think it was #4501. |
Has anyone made this work successfully? I'm seeing the same behavior using the stock httpUpdate example against |
I have not yet encaged a way to do OTA updates using HTTPS. nothing worked. |
I would say that 8266 does not have the memory to handle a whole firmware update over SSL. If you can devise a way to get the update in 4K chunks for example, it could work. Though it might take quite a bit longer... |
That's pretty much what I had expected. I've implemented a ridiculous workaround by way of a reverse proxy that will deliver the binary from GitHub over plain HTTP. |
There is a PR for a different SSL which doesn't need dynamic memory allocation after it's initiated (#4273) and supports the http update (you need to pass in a uint8_t[20] instead of a hex string to the constructor and everything else is identical as far as the updater API). It may not work in your case, but it may be worth a try to avoid the workaround you've had to implement... |
Has anyone managed to make it work ?? how to do this using http proxy? |
@lucasromeiro my case is pretty simple and the solution I've applied is straightforward. I've spun up an Ubuntu server in Azure, deployed NGINX, registered
When a user requests I've also put CloudFlare in front of this to cache the |
If ESP8266's memory is too limited to work with SSL, it may useful to add in the httpUpdate an option to sign the binary or even fully crypt it? Connection may not be secure but at least the file could be authenticated. |
Ok guys - still not working. My server only "speaks" https, I added the required ciphers and |
I could not do it either. I think I will have to create another domain with another server that is http to be able to do the update ota ... because the current library can not manage the memoia. |
It seems to be working now. My server only speaks https, I added the required codes and test the connection:
It returns with "certificate match" . However, continuing with
returns with the dreaded "connection refused". I tried
and that also worked ok. I was able to see the URI in the servers log-file. But any attempt to do
fails with connection refused without log-file entry on the server. So - ESPhttpUpdate.update(..) doesn't even come to the point where it actually requests anything. HOWEVER: Changing the URI to something that ends in ".bin"
allowed the update-process to proceed (server log entry above). So it seems the "Connection refused" error is .. emm .. bogus. Has nothing to do with a connection, but the filename(URL, URI) needs to be correct. Hope that helps. |
So as this is still open, does anyone have an example of using the BearSSL implementation with httpUpdate? I'm happy to start tinkering here, but can't quite figure out how to make it all fit together... |
You could try the changes in #4980 |
Any news on that? |
Absolutely. Been doing that for several months now. However, you need to set the HTTPS params somewhat different (server side). My server runs PHP and I set the ciphers to: DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA:KRB5-DES-CBC3-MD5:KRB5-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:EDH-DSS-DES-CBC3-SHA:DES-CBC3-SHA:DES-CBC3-MD5:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:AES128-SHA:RC2-CBC-MD5:KRB5-RC4-MD5:KRB5-RC4-SHA:RC4-SHA:RC4-MD5:RC4-MD5:KRB5-DES-CBC-MD5:KRB5-DES-CBC-SHA:EDH-RSA-DES-CBC-SHA:EDH-DSS-DES-CBC-SHA:DES-CBC-SHA:DES-CBC-MD5:EXP-KRB5-RC2-CBC-MD5:EXP-KRB5-DES-CBC-MD5:EXP-KRB5-RC2-CBC-SHA:EXP-KRB5-DES-CBC-SHA:EXP-EDH-RSA-DES-CBC-SHA:EXP-EDH-DSS-DES-CBC-SHA:EXP-DES-CBC-SHA:EXP-RC2-CBC-MD5:EXP-RC2-CBC-MD5:EXP-KRB5-RC4-MD5:EXP-KRB5-RC4-SHA:EXP-RC4-MD5:EXP-RC4-MD5 |
On this topic, what TLS version and which specific ciphers does lwip support? |
@CRCinAU lwip doesn't, It's just the TCP/IP stack and low level sockets. The secure layer is built on top of that and is provided by BearSSL. If you want to know the ciphers, please check their webpage. |
Ahhh good. From: https://bearssl.org/support.html#supported-versions The supported ciphers are available here: |
Hello, I do not understand how it works. is there any complete example? I need to update ota through the file link. |
Closing as there are examples w/OTA https update using BearSSL thanks to @d-a-v. |
So I'm starting to revisit this again as in theory its fixed - but I'll be buggered if I can find the examples referenced and attributed to @d-a-v ... Can someone post a link to these? I can find this issue in Google, but not the new OTA examples using BearSSL etc... |
Searching further, I came up with this: Currently, I'm using the following code:
If I use www.example.com, I get a the following output: If I change this to the IP address of the host, ie a 10.1.1.1 address, then everything works fine. I'm trying to get some debug happening to figure out why this is the case - will post if / when I find anything - but hoping someone has a bit more insight than me :\ |
@earlephilhower was in fact explaining I requested availability of such example for the community. He did the job. You found the good example.
"then everything works fine" => I don't get your issue |
GAH. This turned out to be a networking issue. The server in question is behind a DMZ. There is a DNAT for public IP -> 10.x.x.x address in a different part of the network. This was masked from debugging on a desktop because this was still working fine over IPv6 - which does not use DNAT. As the ESP8266 bits don't support IPv6, it was failing because the DNAT was causing a RST to be sent back to the initial SYN. Once I disabled IPv6 on my desktop, I could replicate the same problem. Dammit. Sorry for the noise - the code I posted works fine - as long as your network is behaving :) |
On another note though, the binary size has gone from 361344 bytes to 473728 bytes just by including the BearSSL updater. Is this just a fact of life, or is there optimisations that can be achieved to not interfere with these updates and program size? EDIT: Further, on a 4Mb flash chip, if I use EDIT2: It seems even a very minimalistic program that only has a simple web page and does an OTA from a https source produces the following:
The dependency graph for this simple program is:
Ouch. |
I claim it does :) |
yes |
Interesting. Does anyone seem to make an ESP01 with a 4MB flash chip? Is it only a DIY to replace the chip by hand? I can see myself coming across pain in the future ;) |
I don't understand your troubles. I am communicating and OTA'ing all sorts of ESPs via SSL without any problems. Just adapt the SSL/TLS protocols in your server setup. m. |
I'm aware I'm starting to wander off-topic here - but if I replace the flash chip with a 4MB one (using there: https://www.aliexpress.com/item/10piece-W25Q32FVSIG-W25Q32FVSSIG-25Q32FVSIG-W25Q32-SOP-8-new-original/32946698708.html ) - what profile do I use for the new flash layout? I notice esp01.json and esp01_1m.json. Would I end up having to duplicate esp01_1m.json to something like esp01_4m.json and just change the values of 1048576 to 4194304 and use |
Probably, best would be to run the arduino IDE, build and check command line. |
Ok - so back to the problem with OTA updates... I've been using the stage branch in building my code, but even uploading a .bin to $ip/update is causing issues. From a tcpdump, it seems that things are running way too slow for what they should be....
10.1.1.156 is an ESP01, 10.1.1.82 is my desktop. If I try to flash via the ESP01 retrieving via a web server, it comes up with the Error 6 read timeout. If I try to upload to the ESP01's onboard web server, that eventually times out in the browser. I cracked open a new ESP01S to flash via USB and test, and I get the same results when trying to OTA (using both methods). Where should I start to debug this? |
Further to my last, if I change the update code to the following, all works well:
ie - not using a https source is fine. |
To add more information - the logs from my server showing timestamps during the update process. Changing ONLY the below lines of code vs the result: Using:
Log results:
When switching to BearSSL / https code:
Logs show:
|
And now that I've posted all this, I just updated to:
And the problem seems to have gone away.... Both http and https works again:
Maybe I just seem to find things at the wrong times 👎 I've also found that the latest lot of updates has broken FastLED as well - apparent due to new typedefs? |
Refer this HTTPS is working for me |
Basic Infos
Hardware
Hardware: ?ESP8266-12E?
Core Version: ?2.4.0?
Description
OTA update without SSL is working fine. With SSL is it throwing error.
I generates FP through following command.
openssl x509 -noout -fingerprint -sha1 -inform pem -in C:\HTTPS\sipl.crt
Settings in IDE
Module: ?Generic ESP8266 Module?
Flash Size: ?4MB(3M SPIFFS)?
CPU Frequency: ?80Mhz?
Flash Mode: ?DIO?
Flash Frequency: ?40Mhz?
Upload Using: ?SERIAL?
Reset Method: ?ck?
Arduino SDK: ?1.8.5?
Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: