Alessio Grespi

Down the device-certificate rabbit hole

· Also on Substack

Down the device-certificate rabbit hole

On Christmas night 2025 I made my first device certificate. Eleven months later I think I’ve finally got it right.

Every device that talks to a server has to prove who it is. The grown-up way is an X.509 certificate: an ID card the device shows on every connection. The certificate isn’t the hard part. Getting a unique one onto every device, without anyone typing secrets in on a bench, is.

Here’s how I got there, the long way round.

1/ One certificate for everyone

25 December, 23:17: initial commit. By the next evening an ESP32 was talking to AWS IoT with one certificate and its private key pasted into the firmware. And committed to git. The Amazon root certificate in my Terraform was AI-generated nonsense ending in “5J5q5J5q5J5q”. A fake certificate in a file about trust.

2/ AWS fleet provisioning

Three hours later, devices used a shared “claim” certificate to ask AWS for their own. Better, except AWS generates each device’s private key and sends it down the wire.

3/ The vending machine

To get the claim certificate out of the firmware, I built an API to hand it out: API Gateway, Lambda, DynamoDB, serving a shared certificate and its private key. For its first week and a half it had no authentication. A vending machine for private keys. 79 AWS resources so one ESP32 could say hello. Classic serverless. Commit messages that month: “idk”, “it works v2”, “aaaaaaaaa”. Mostly at 2am.

4/ Then I went backwards

April: I swapped Cursor for Claude Code, and the game changed. I didn’t stop learning. I stopped learning line by line and started learning what matters: architecture and systems integration. I (Claude) built my own CA and broker, wrote “private key never leaves the device” in the design doc, then generated keys on the server anyway, and switched revocation checking off because it blocked every connection. June: passwords. August: LoRaWAN, a change of direction and pace, no certificates at all. I took a break from them, learned LoRaWAN instead, building the foundational blocks and going deep on the fundamentals of LoRa-based IoT.

5/ We’re back

The device generates its own key, and the key never leaves it. It sends us only the public half, we sign its ID card, and it connects to our own server with it. We never hold anything that could pass for one of your devices, so even if our database leaked, nobody could pose as one.

19 November: Live 39 minutes after the commit. By 17:36 a board on my desk had taken its first remote firmware update, in 31 seconds. By 18:14 I could cut it off with one click. Somewhere in between I deleted the address that had pointed our devices at AWS since January.

What I’d tell December me: embrace the Claude Code, but remain curious.

More writing

Newsletter

New notes by email. Essays and application notes on building hardware.

London, UK · English, Italian, Spanish, Russian, French Rev. 2026.12 · © 2026