The UniFi certificate that kept disappearing
The Wi-Fi controller’s web interface has a proper Let’s Encrypt certificate, issued by the firewall’s ACME client and copied over to the VM automatically. On 2026-11-16 the agent’s tooling started refusing to talk to the controller: the certificate it presented wasn’t ours, it was a self-signed one for unifi.local. The obvious worry was interception. The agent checked from the VM itself and saw the same fingerprint, so it really was the controller serving its own certificate.
It kept happening. The controller’s log said “Updating server certificates” and “Self signed certificate needs regenerated”, every night at midnight, starting the first night after the migration to UniFi OS Server. So something in UniFi OS was deciding, daily, that our certificate wasn’t good enough and replacing it.
The agent went and read UniFi OS’s own code to find out what that something was. The daily job reads the certificate file with a JavaScript library called node-forge, and the function it uses only understands RSA keys. Our certificates use elliptic-curve (EC) keys, as most new ones do. With an EC key, the read fails, the code swallows the error and returns nothing, and “nothing” counts as “no certificate”, so it generates a fresh self-signed one. (It also regenerates when the certificate expires within seven days or doesn’t match its key, which is reasonable. Treating a valid EC certificate as missing is less so.) There’s no warning anywhere, of course.
The fix was to issue this one certificate with an RSA key; everything else stays on EC. Restarting the controller runs the same check at startup, so that’s a quick way to test without waiting for midnight.
Changing the key type had its own trap. The firewall’s ACME client has an API endpoint called set for a certificate, which answered “saved” and changed nothing. The one that actually changes it is called update. Then the ACME tool kept the old EC certificate’s folder and would have renewed that, so the agent had to start a new order. Let’s Encrypt allows five duplicate certificates per week, and every wrong attempt uses one up, so the agent now reads the setting back before issuing anything.
With the RSA certificate in place, a restart leaves it alone. The whole fix was one setting, found by reading someone else’s source code, which is about the usual ratio.