IoT Device Identity: Provisioning, Certificate Rotation, and Factory Secrets

In early November, during a routine review with our security consultant, he put a single question on the table: "Do all 12 thousand devices in the field have the same MQTT password?" Silence. It wasn't the same password, but the truth wasn't much brighter: device identity was a username derived from the serial number plus a token loaded from a CSV file on the production line. That CSV file sat on the desktop of an engineer at our manufacturing partner, with one copy in an email attachment and another in a shared folder. In other words, the identity of our entire fleet was wandering around three computers we had never audited. That day we stopped treating provisioning as a "manufacturing detail" and declared it an architectural problem.

Where Is an Identity Actually Born?

In IoT, the identity debate usually starts with "X.509 or tokens?"; I think that's the wrong place to start. The real question is this: where, and in front of whose eyes, does the device's secret first come into existence? In our old flow, the secret was generated in the cloud and carried to the factory via CSV — meaning it passed in front of at least four systems and several people. In the target flow, the secret isn't carried anywhere: the device generates its own key pair internally, the private key never leaves the silicon it was born in for its entire life, and only a CSR goes out to be signed. What made this possible in hardware was a secure element; balancing cost and supply, we chose an ATECC608-class chip, at a cost increase of roughly $1.10 per device. When I defended that figure to the board, I used a single slide: the penalty a single mass identity leak would trigger under our customer contracts.

The flow on the production line was set up like this: on first boot, the device generates a key inside the secure element, the fixture at the production station takes the CSR from the device and forwards it to our HSM-backed intermediate CA in İzmir; the CA matches the device's serial number against the production order and returns the certificate within 90 seconds. There are no persistent secrets in the factory, the station itself authenticates with mTLS, and every signing operation lands in an audit log. Even if the manufacturing partner changes — which it did once within two years — the identity chain stays in our hands.

The device generates its key pair internally, the fixture forwards the CSR to the intermediate CA, and the certificate returns to the device in 90 seconds.
No persistent secrets in the factory; even if the manufacturing partner changes, the identity chain stays with us.

The First Wrong Hypothesis: "Issue a 20-Year Certificate and Be Done with It"

The topic that met the most resistance in design meetings was rotation. The view that "the device lifespan is 10 years, so issue a 20-year certificate and don't bother with rotation" gathered serious support within the team, and I'll admit that for a while I was close to being convinced myself. What turned us away from the idea wasn't a theoretical security debate but a concrete incident we went through: we discovered a configuration error in the first version of our intermediate CA — an extension in the signed certificates was wrong, and some TLS stacks might reject it down the line. There were 3,200 devices in the field with certificates signed by that CA. Had the certificates been valid for 20 years, that error would have been a 20-year debt; because we had rotation infrastructure, we moved the entire fleet to new certificates in 6 weeks. You need rotation not because certificates get old, but because you will make mistakes. Any identity infrastructure design that assumes you won't make mistakes is a design that makes mistakes permanent.

The rotation mechanism itself looks simple on the surface: once two-thirds of the certificate's lifetime has passed, the device generates a new key pair, sends a CSR over mTLS using its current identity, receives the new certificate, and uses it from the next connection on. The devil is in the details: the old certificate isn't deleted until the first successful connection with the new certificate — otherwise a power cut right at the moment of switchover leaves the device without an identity. We experienced exactly this on 7 devices in the first pilot; rotation itself has to follow A/B logic and be reversible. In addition, rotation timing is spread across the fleet; 12 thousand devices rushing the CA in the same week would be a self-inflicted DDoS. Today our CA processes an average of 60-70 renewals a day, and that pace is a flat line on the dashboard.

Long-lived certificates make mistakes permanent; rotation made it possible to fix the intermediate CA error in 6 weeks.
You need rotation not because certificates get old, but because you will make mistakes.

No Clock, No Certificate

The least discussed enemy of X.509 in IoT is the clock. Certificate validation asks "is this valid right now?", and for a device whose RTC battery has died and whose clock has reset to the year 2000, every certificate in the world is "not yet valid." In this scenario the device can't establish TLS; without TLS it can't get NTP (our NTP traffic was authenticated too); without NTP its clock doesn't get fixed — a perfect deadlock. Our solution is layered: the device writes the time of its last successful connection to flash, and on boot, if the clock is earlier than that, it trusts this value rather than the RTC; if it still can't connect, it connects to a special "clock recovery" endpoint that relaxes only the certificate time check but still verifies the server's identity against a pinned root, and gets a trusted time. This endpoint can't do anything else. It sounds like a fringe detail; in the field, our rate of devices with RTC problems is 4 per thousand per year, and without this mechanism every one of them would mean a technician visit.

What the Revocation List Looks Like in the Field

Then there's the scenario nobody plans for on day one: how do you kill a device's identity when it's stolen or a customer contract ends? The classic answer is CRL/OCSP; in the embedded world, both are clunky. We put revocation in the authentication layer in front of the broker: on every connection, the certificate's fingerprint is checked against a revocation set we keep in Redis — at a cost of 0.3 milliseconds per connection. The only thing that writes to the revocation set is our inventory system; the moment a device is marked "scrapped" or "lost," its identity dies within 30 seconds. By the end of the first year, there were 41 devices on this list; two had genuinely been stolen, and one tried to connect from another city three days after it was stolen. It couldn't. When I put that log line into the security report, I'll admit I shuddered, remembering the CSV file from a year earlier.

The older devices in the field are a separate story: 4,600 of the 12-thousand-unit fleet were older hardware without a secure element, and recalling them was out of the question. We set up an interim regime for them: the key is still generated on the device, but in software, and stored in a region of flash with read protection enabled; certificate lifetimes are a third of those for the new devices, and on the broker side these devices are tagged in a separate trust class — critical command channels are closed to them. It isn't perfect; but it beats the "if we can't replace them all, let's do nothing" trap. Fleet security isn't a binary switch; it's a graduated risk map.

On new devices the key lives inside the secure element; older hardware runs with restricted permissions in a separate trust class.
Better than the "if we can't replace them all, let's do nothing" trap.

This entire transformation — secure element, factory flow, intermediate CA, rotation, revocation — was completed in four months with the part-time effort of two engineers. The most expensive item wasn't the software but recertifying the production line fixture. Looking back, I can see that the most critical decision wasn't technical but organizational: the owner of the identity infrastructure is no longer "manufacturing" but the architecture team. As long as provisioning remains an Excel job, even the best cryptography is at the mercy of an email attachment. If your own fleet's identity story still passes through a CSV file — and in more than half of the projects I see, it does — reach out through the contact page; I'll gladly share our factory flow diagram and rotation state machine.

In security, the phrase "device identity" sounds like a feature. It isn't. It's a life story that runs from the device's birth to the day it's scrapped, and in every chapter of that story the same question gets asked: how many eyes can see this secret right now? The right answer is the same in every chapter: zero.