ACME isn't just for public certs: automatic certificates from the CA on my NAS
I’ve had an internal CA on my NAS for a while now. TrueNAS will happily make you one under Credentials → Certificates, and mine signs the NAS’s own web UI cert and a wildcard for my internal names. Most of my devices already trust the root.
What it didn’t have was any way for an app to ask for a certificate by itself. So every new thing on the network (a Grafana here, an LLM gateway there) ended up with a hand-made cert I’d forget to renew, or a self-signed one and a browser warning I’d trained myself to click through. Two of the certs on the NAS had already quietly expired, which tells you how well “I’ll remember to renew it” works.
So what’s the problem?
Everyone knows the fix for this on the public internet, it’s ACME. Certbot, Caddy, Traefik, lego; point them at Let’s Encrypt and certificates stop being a thing you think about.
For internal stuff, the usual advice is to use Let’s Encrypt anyway, and that’s where it gets awkward. A public CA has to validate you from the public internet, which leaves two choices:
- HTTP-01, where Let’s Encrypt connects to your app on port 80. That means your “internal” app is reachable from the internet, at least a bit.
- DNS-01, where you prove control by publishing a TXT record. Nothing needs to be reachable, but now every box that wants a cert is holding an API token for your public DNS zone (or you build some delegation to avoid that), and all your internal hostnames end up in certificate transparency logs for the world to read.
Neither is terrible, but both drag public infrastructure into a problem that’s entirely private.
ACME is a protocol, not a Let’s Encrypt feature. Nothing says the server on the other end has to be a public CA.
If the ACME server lives on your own network, HTTP-01 is just one internal box connecting to another internal box on port 80. No public DNS, no tokens, no inbound anything.
The solution? step-ca, on the NAS
step-ca from the lovely people at Smallstep is an open source CA that speaks ACME. I did this one with Claude, working from one of my Agent Sandboxes workspaces and driving the NAS through the TrueNAS API, with me on firewall duty. The shape of it:
- A new intermediate CA, signed by the existing root. Created inside TrueNAS, so the root key never leaves it. step-ca only ever holds the intermediate (EC P-256, five years, not allowed to sign further CAs). Anything that trusts my root already trusts whatever step-ca issues, which is the whole reason for building on the CA I already had.
- A dataset for step-ca’s state, holding the certs, the intermediate key, the config and its little database.
- step-ca as a TrueNAS custom app, which is a compose file and not a lot else:
services:
step-ca:
image: smallstep/step-ca:0.30.2
restart: unless-stopped
user: "1000:1000"
ports:
- "9000:9000"
environment:
STEPPATH: /home/step
volumes:
- /mnt/nvme-app-pool/step-ca:/home/step
entrypoint: ["/usr/local/bin/step-ca"]
command: ["/home/step/config/ca.json"]
The interesting part of ca.json is the provisioner and the policy:
"policy": {
"x509": {
"allow": {"dns": ["*.in.metahertz.dev"], "ip": ["10.30.0.0/16"]},
"allowWildcardNames": false
}
},
"provisioners": [
{
"type": "ACME",
"name": "acme",
"challenges": ["http-01"],
"claims": {"defaultTLSCertDuration": "720h", "maxTLSCertDuration": "2160h"}
}
]
HTTP-01 only, 30 day certs (90 at the very most), and it’ll only issue for my internal names and my internal address range. TrueNAS can’t put name constraints into the intermediate certificate itself, so that policy block is the thing stopping a compromised app asking for google.com and getting it. Wildcard certs are refused outright; if every app can get its own cert in seconds, nobody needs a wildcard to pass around.
Bonus: it’ll issue for bare IP addresses. A few of my things get addressed by IP, and being able to give them a real cert is rather nice.
What went wrong on the way
It wouldn’t be much of a post if it all just worked.
step-ca’s wildcards match one label, not “everything below”. My internal names look like nas.30.in.metahertz.dev, and *.in.metahertz.dev in the policy flatly refused them. The obvious fix, a leading-dot .in.metahertz.dev, stopped step-ca from starting at all (five minutes of no CA, oops). The fix that actually works is not pretty, the config now lists *.0.in.metahertz.dev through *.255.in.metahertz.dev. All 256 of them. Generated by a three line script, and I’m choosing not to look at it again.
The firewall rules go in both directions, and the second one is backwards from what you’d guess. Each VLAN that wants certs needs:
- the VLAN → the NAS on 9000, so clients can talk to the CA
- the NAS → the VLAN on 80, because with HTTP-01 it’s the CA that connects to the app
I got number two the wrong way round the first time. step-ca checks the challenge while it’s handling the client’s request, so when the NAS can’t reach port 80 nothing fails helpfully, the client just hangs for thirty seconds and gives up. If your first issuance sits there doing nothing, go and look at which way your port 80 rule points.
The TrueNAS API hands back private keys. This is the one I’d really like you to take away. When you create a CA through the API, the response includes the issuing CA in full, private key and all. One unfiltered print of that response and my root CA’s key was sitting in an AI session transcript. SadFace. The whole design was about the root key never leaving TrueNAS, and it left anyway via a debug print. So the root got rotated (cheap to do, with only two leaf certs and one intermediate hanging off it) and that API key is getting revoked too. If you script against those endpoints, pick out the fields you want and never dump the whole reply.
Using it
Once the rules were in, the first certificate came straight out. It was for one of the LLM boxes, by IP address, valid 30 days and verifying against the root. Certificate issued, finally!
From there any ACME client will do, it just needs the directory URL and a copy of the root to trust for the connection to the CA itself. In Caddy that’s two lines of global options:
{
acme_ca https://ca.30.in.metahertz.dev:9000/acme/acme/directory
acme_ca_root /etc/caddy/root_ca.crt
}
or with lego:
LEGO_CA_CERTIFICATES=root_ca.crt lego \
--server https://ca.30.in.metahertz.dev:9000/acme/acme/directory \
--email you@example.com --domains myapp.30.in.metahertz.dev --http run
After that it’s the same deal as Let’s Encrypt, the client renews by itself and I get to stop thinking about it.
The CA also gets watched like anything else. A blackbox exporter next to it probes /health and the ACME directory every minute, with a dashboard in the NAS’s Grafana. step-ca renews its own TLS certificate daily, so if that cert ever has less than a couple of hours left you know its renewal has broken well before any app notices.
TL;DR
- ACME works just as well against a CA you run yourself as it does against Let’s Encrypt.
- With the CA inside your network, HTTP-01 never leaves it. No public DNS records, no DNS API tokens on every box, no internal hostnames in transparency logs.
- step-ca in a container, an intermediate signed by the root you already have, and a name policy so it can only issue for your own stuff.
- Two firewall rules per VLAN: clients to the CA, and the CA back to clients on 80.
- Careful what you print from the TrueNAS certificate API!
The trade-off is the obvious one, you’re running a CA now, and the intermediate key sits on the NAS, so look after it. For a home or office network where the alternative was a pile of self-signed certs and expired ones, I’ll take that all day.
I hope this helps someone out, and let me know if you’ve got a tidier answer to the 256 wildcards.
Happy hacking!
-Matt