LOGBOOK

HELP

1 / 16
Other keys: show • Space: good • 1-4: rate • 0: skip • 5: flag

Question

An ESP32 garage-door remote sends its commands as plain HTTP to a NodeJS server over open Wi-Fi. What has to change on the server, on the ESP32 and on a laptop client to protect the traffic end to end with TLS?

Answer

The server gets a private key and a certificate and serves HTTPS. Every client (the ESP32 firmware and the laptop's curl) gets a copy of that certificate as its trust anchor and refuses any server that cannot prove it holds the matching key.

openssl creates a key and a self-signed certificate on the laptop; the key stays in the NodeJS server, the certificate is copied into the ESP32 firmware and to curl

* The certificate is public and goes to every client; the key never leaves the server. *

"End to end" means the protection runs from the device's program to the server's program, so nothing between them (the open Wi-Fi, the access point, anyone who has joined the network) can read or change the commands. The work, in order:

  1. Make an identity for the server. openssl generates a key pair and a self-signed certificate that binds the public key to the server's address.
  2. Server: load the key and the certificate and listen with TLS. In Node.js that is https.createServer({ key, cert }, app) instead of http.createServer(app). The routes, such as POST /opengaragedoor, stay the same.
  3. ESP32 client: embed the certificate in the firmware, switch the URL from http:// to https://, and hand the certificate to the HTTP client so it can verify the server. Then rebuild and flash, because the certificate is now part of the image.
  4. Laptop client: tell curl to trust that same certificate: curl --cacert garagedoor.cert -X POST https://<server>:8080/opengaragedoor.
  5. Check with Wireshark that the captured packets now show a TLS handshake and encrypted records instead of readable HTTP.

Nothing about the buttons, the FreeRTOS tasks or the door logic changes. TLS sits between TCP and HTTP, so the application keeps sending the same requests and the library underneath encrypts them.

Go deeper:

or press any other key

Question

SSL or TLS: what is the difference, and which version should an IoT device use today?

Answer

SSL is the old Netscape protocol; TLS is its standardised successor. Every SSL version and TLS 1.0/1.1 are deprecated. Use TLS 1.2 or TLS 1.3. "SSL certificate" is just the everyday name for the X.509 certificate TLS uses.

Version Year Status
SSL 2.0, SSL 3.0 1995, 1996 Broken and prohibited (SSL 3.0 deprecated by RFC 7568)
TLS 1.0, TLS 1.1 1999, 2006 Deprecated by RFC 8996 (2021)
TLS 1.2 2008 (RFC 5246) Still fine with modern cipher suites. This is what the garage-door log shows (SSL connection using TLSv1.2)
TLS 1.3 2018 (RFC 8446) Current: one round trip less, only forward-secret key exchanges, certificate encrypted

The name SSL survives everywhere: "SSL certificate", the library OpenSSL, curl's SSL connection using … line. None of that means the old protocol is in use. A certificate is not tied to a protocol version at all; the same certificate works for TLS 1.2 and 1.3.

For an ESP32, both TLS 1.2 and 1.3 are available through mbedTLS in ESP-IDF. TLS 1.2 is the more widely supported default; TLS 1.3 saves a round trip on every new connection, which matters on battery.

Go deeper:

or press any other key