I want to develop a product, a home smart thermostat which will have a web interface. The web interface would make requests to the thermostat which is controlled by an ESP8266-based wemos mini d1. And I would like to connect the frontend and the backend securely if it will be a product.
I tried making the backend to accept https requests and generated the key and cert using openssl. But when I ran the program, only the http site loaded in the browser and the https didn't (not even a 'not secure' page). I used the local ip address in the browser like this: https://192.168.1.5/
BearSSL::ESP8266WebServerSecure server(443);
ESP8266WebServer serverHTTP(800);
void serveHomepage() {
server.send(200, "text/plain", "Hello world https");
}
void serveHomepageHttp() {
serverHTTP.send(200, "text/plain", "Hello world http");
}
void setup() {
connectToWifi();
configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov");
serverHTTP.on("/", serveHomepageHttp);
serverHTTP.begin();
server.getServer().setRSACert(new BearSSL::X509List(serverCert), new BearSSL::PrivateKey(serverKey));
server.on("/", serveHomepage);
server.begin();
}
void loop(){
server.handleClient();
serverHTTP.handleClient();
}
I barely found any documentation or a full demo, I followed this article: https://www.onetransistor.eu/2019/04/https-server-on-esp8266-nodemcu.html
I also read that https is relatively memory and cpu intense, so I would rather connect the esp8266 with http to a proxy/gateway server which has HTTPS support (but is not on the same network), and then that to the frontend:
Frontend -> HTTPS request to central server -> HTTP request to esp8266
I don't really know if it is secure enough, but I assume that the users that use my product have a secure home wifi and my server provider is also reliable.
So, what are my opportunities, if I want to provide my users good security with an ESP8266? Is the https proxy server mentioned above a secure enough solution?