My company is going to use ESP32 in their devices. I have to write code that allows downloading ESP32 OTA updates from an HTTPS server. The TLS server's root certificate expires once a year. Here is my question: How can I safely download a new certificate from the server if it has expired? If the certificate expires, I lose remote control of the ESP and can't upload new files to it. For example, web browsers like Chrome or Firefox (as I understand) update their CA store, and users don't even notice it. Is it possible to achieve that functionality on the ESP32?
The only idea I have is to connect with a second website which is HTTP, not HTTPS, and download the new certificate. But I must use TLS all the time, so this solution is unacceptable. Im new in web technology and preciate ane help and tips!
Are you sure the server uses a root certificate, not some intermediate one? The difference between a browser and embedded device is that you can still update a browser with a simple offline installer no matter how out of date your current version is. With an embedded device the OTA server is the only lifeline - if device can't talk to server, it can't update. It becomes a zombie and can only be updated via cable, which is usually not feasible.
If your embedded device's OTA relies on PKI with 1-year root certificate, I'd say you're in a bad place. This requires that each and every device without exception updates their root certificate before the previous one is rotated, anyone left behind is a zombie. If you're sure you can update them all before the deadline, go ahead and do that. Pay attention to devices which don't have internet access for months (e.g. because they are sitting in a warehouse).
This is my list of solutions in order of personal preference:
You can replace 50 years with any number X if:
I've struggled to find good reference material on X.509 certificates and chains (90% of google matches are shallow sales articles). I can point you to an article Illustrated X.509 Certificate and the Wikipedia page