Skip to content

Field notes · Cybersecurity

Run Your Own ACME CA With step-ca, Then Break TLS Trust on Purpose

Trusted HTTPS for homelab services means running a small certificate authority, and most guides stop at the first green padlock. I stood up step-ca with an ACME provisioner, had Caddy order a certificate from it, then broke trust six ways and captured the exact error each client printed.

Table of Contents
Environment Throwaway Docker container on a BytesNation VPS: debian:trixie pinned by digest (Debian 13), host kernel 7.0.0, Docker 29.10.1, docker-init as PID 1, no systemd, step-ca 0.30.2, step CLI 0.31.0, Caddy 2.11.9, OpenSSL 3.5.9, curl 8.14.1, Python 3.13.5step-castepcaddycurlopensslpython3update-ca-certificatesdocker
Title card reading Run your own ACME CA, then break trust on purpose. Three stacked certificate cards, Root CA, Intermediate CA, and app.lab.internal, joined by a vertical line. A live dot on the last card is labelled Trusted. ACME is how a server gets a certificate, a CA is a certificate authority, and TLS is the encryption HTTPS uses.

Self-signed certificates teach everyone in the house to click through warnings. A private certificate authority fixes that, and it brings its own failure modes. I ran step-ca in one Debian containerA lightweight, portable package that bundles an application with its dependencies and runs in an isolated process on the host OS, sharing the kernel. Read more →, turned on its ACME provisioner, and had Caddy order a real certificate for a small app. Then I broke it on purpose. I served the wrong name, removed the root from the trust store, sent a chain with a missing intermediate, and let a certificate expire. Nothing touched a real network or device. All names are *.lab.internal on 127.0.0.1 inside the container.

When a homelab certificate breaks, the error names a symptom, not a cause. In this run two different faults printed the same line, unable to get local issuer certificate, and one fault printed nothing at all. So before you touch the trust store, check three things in order: who issued the certificate the server sent, whether the server sent the intermediate with it, and only then whether the client trusts your root. The name and the dates come after that.

All output in this note was captured on bn-dev, a throwaway DockerA platform that packages applications into containers, providing a standardized way to build, ship, and run software consistently across any environment. Read more → container on a BytesNation VPS, on Monday, November 30, 2026, between 5:55 AM and 6:24 AM ET.

This note is about software certificates for web services. If you want keys locked in hardware for SSHA cryptographic protocol for secure remote login, command execution, and file transfer over an unsecured network. Read more → and logins, see YubiKey PIV for a zero-trust homelab. If you want a login page in front of your apps, see Authelia and Caddy SSO. TLSThe encryption protocols that secure data in transit between a client and server, powering HTTPS and most encrypted internet communication. Read more → proves which server you reached. SSOAn authentication scheme that lets users log in once and gain access to multiple independent systems without re-entering credentials for each one. Read more → decides who gets in. You want both.

What each failure printed

One line per failure, in the order of the list below. Captured on bn-dev, Nov 30, 2026, with step-ca 0.30.2, step CLI 0.31.0, Caddy 2.11.9, OpenSSL 3.5.9 and curl 8.14.1.

issuer=CN=Caddy Local Authority - ECC Intermediate
...
{"level":"warn","ts":1796036135.6065142,"logger":"http.acme_client","msg":"HTTP request failed; retrying","url":"https://ca.lab.internal:9000/acme/acme/directory","error":"performing request: Get \"https://ca.lab.internal:9000/acme/acme/directory\": tls: failed to verify certificate: x509: certificate signed by unknown authority"}
...
curl: (60) SSL: no alternative certificate subject name matches target hostname 'nas.lab.internal'
...
curl: (60) SSL certificate problem: unable to get local issuer certificate
...
curl: (60) SSL certificate problem: unable to get local issuer certificate
...
curl: (60) SSL certificate problem: certificate has expired
...
The request lacked necessary authorization to be completed: certificate expired on 2026-11-30 10:57:18 +0000 UTC
  1. No error at all. With acme_ca in Caddy’s global options, Caddy still issued the .internal name from its own local CAA trusted entity that issues and signs digital certificates, vouching that a public key belongs to a specific identity. The foundation of PKI trust chains. Read more →, and step-ca’s log shows no request from Caddy. The fix is a tls { ca ... } block on the site.
  2. Caddy reached step-ca and refused its certificate. The ACME client needs your root too. The fix is ca_root in the same tls block.
  3. The client asked for nas.lab.internal and the certificate did not carry that name. The fix is to add the name to the Caddy site, so Caddy orders a certificate with it.
  4. The root is not in the client’s trust store. The fix is to install it, and to take it out again when you are done.
  5. The same line as 4, from a server that sent only its own certificate and not the intermediate. The fix is to send the intermediate too. Check this one first, with openssl s_client -showcerts.
  6. The certificate expired, and then step-ca refused to renew it with HTTP 401. Renew before expiry, or issue a new one through a provisioner.
A map of six TLS failures in three columns: what broke, what you see, and the fix. Caddy asked for a certificate for a .internal name: no error, but the certificate comes from Caddy's own authority; tell the site to use step-ca. Caddy cannot verify step-ca: Caddy says the authority is unknown; give Caddy the root certificate. Wrong name on the app certificate, marked with the one accent dot: the client says the name does not match; add the name and Caddy orders a second certificate. Root is not in the trust store: the client cannot find who issued the certificate; install the root, then remove it afterwards. Server sends the leaf only: the same symptom; send the intermediate too. Certificate expired: the client says it has expired; renew before it expires, because an expired certificate cannot be renewed. A CA is a certificate authority, TLS is the encryption HTTPS uses, and ACME is how the certificate was issued.What broke, what you see, and the fix for six TLS failuresA map of six TLS failures in three columns: what broke, what you see, and the fix. Caddy asked for a certificate for a .internal name: no error, but the certificate comes from Caddy's own authority; tell the site to use step-ca. Caddy cannot verify step-ca: Caddy says the authority is unknown; give Caddy the root certificate. Wrong name on the app certificate, marked with the one accent dot: the client says the name does not match; add the name and Caddy orders a second certificate. Root is not in the trust store: the client cannot find who issued the certificate; install the root, then remove it afterwards. Server sends the leaf only: the same symptom; send the intermediate too. Certificate expired: the client says it has expired; renew before it expires, because an expired certificate cannot be renewed. A CA is a certificate authority, TLS is the encryption HTTPS uses, and ACME is how the certificate was issued.What broke, what you see, and the fixWHAT BROKEWHAT YOU SEETHE FIXCaddy asked for a certificate for a.internal nameNo error, but the certificate comes from Caddy's ownauthorityTell the site to use step-caCaddy cannot verify step-caCaddy says the authority is unknownGive Caddy the root certificateWrong name on the app certificateThe client says the name does not matchAdd the name, and Caddy orders asecond certificateRoot is not in the trust storeThe client cannot find who issued the certificateInstall the root, then remove itafterwardsServer sends the leaf onlyThe same symptom as the row aboveSend the intermediate tooCertificate expiredThe client says it has expiredRenew before it expires. An expiredcertificate cannot be renewed.Two different faults give the same symptom. The leaf is the server's own certificate. A CA is a certificate authority.TLS is the encryption HTTPS uses. ACME is how the certificate was issued.
Six ways the lab broke, what you see in plain words, and the change that fixed it. Two different faults give the same symptom, so read the chain before you blame the trust store.

Concepts at a glance

Certificate authority (CA):A key pair whose job is to sign other certificates. Clients trust a site's certificate because it chains back to a CA certificate they already hold.Full definition
Root and intermediate:The root CA signs one intermediate CA, and the intermediate signs your server certificates. The root key can then stay offline. Clients store only the root. The server must send its own certificate plus the intermediate.
ACME:Automatic Certificate Management Environment, RFC 8555. The protocol Let's Encrypt made common. A client asks for a certificate, the CA hands back a challenge, the client proves it controls the name, and the CA signs. step-ca speaks the same protocol on your LAN.
http-01 challenge:The CA fetches http://NAME/.well-known/acme-challenge/TOKEN on port 80 and checks the response. If it gets the right answer, the client controls that name. That means the CA has to resolve the name and reach port 80.
Subject Alternative Name (SAN):The list of names a certificate is valid for. Modern clients check the name you typed against this list and ignore the old Common Name field. If the name is not in the list, the connection fails.
Trust store:The set of root certificates a client accepts. On Debian, curl, OpenSSL and Python read /etc/ssl/certs/ca-certificates.crt, built by update-ca-certificates from Mozilla's list plus anything in /usr/local/share/ca-certificates.

The setup

Everything ran in one throwaway Debian container. step-ca listened on port 9000, Caddy on 80 and 443 in front of a small Python app on 8080, and three lab names pointed at 127.0.0.1. Caddy ordered its certificate from step-ca over ACME with the http-01 challenge. The commands, the configs and every output block from the run are in the Go deeper section at the bottom.

One Linux host running three programs. step-ca, the certificate authority with a root and an intermediate and an ACME provisioner, sends certificates to Caddy, which runs the ACME client and listens on ports 80 and 443. Caddy forwards requests to the app on a local port. Below, a band lists four steps: Caddy asks step-ca for a certificate, step-ca checks the request by fetching a challenge file from Caddy on port 80, step-ca hands back the certificate and the intermediate, and a client connects to Caddy on port 443 which passes the request to the app. A dashed line joins the clients to the system trust store. One live dot marks Caddy. ACME is Automated Certificate Management Environment, a CA is a certificate authority, and TLS is Transport Layer Security.step-ca, Caddy and app on one host, and how a certificate gets issuedOne Linux host running three programs. step-ca, the certificate authority with a root and an intermediate and an ACME provisioner, sends certificates to Caddy, which runs the ACME client and listens on ports 80 and 443. Caddy forwards requests to the app on a local port. Below, a band lists four steps: Caddy asks step-ca for a certificate, step-ca checks the request by fetching a challenge file from Caddy on port 80, step-ca hands back the certificate and the intermediate, and a client connects to Caddy on port 443 which passes the request to the app. A dashed line joins the clients to the system trust store. One live dot marks Caddy. ACME is Automated Certificate Management Environment, a CA is a certificate authority, and TLS is Transport Layer Security.ONE LINUX HOST, ALL ON 127.0.0.1step-caca.lab.internal:9000root + intermediateACME provisionerroot_ca.crtCaddy:80 and :443ACME clientapp127.0.0.1:8080python3 http.serverACMEHOW A CERTIFICATE GETS ISSUED1. Caddy asks step-ca for a certificate for app.lab.internal. Caddy trusts the root, so the call works.2. step-ca checks the request by fetching a challenge file from Caddy on port 80.3. step-ca hands back the certificate and the intermediate.4. A client connects to Caddy on port 443, and Caddy passes the request on to the app.curl / openssl / pythonthe clients/etc/ssl/certssystem trust store/etc/hosts maps ca, app, nas .lab.internal to 127.0.0.1 for the lab.ACME is Automated Certificate Management Environment. A CA is a certificate authority. TLS is Transport Layer Security.
step-ca, Caddy, and the app all run on one host. Caddy orders a certificate from step-ca over ACME, proves control of app.lab.internal on port 80, and serves the leaf plus intermediate on 443. Clients only trust it if the lab root is in their trust store or passed with --cacert.
NameListens onRole
ca.lab.internal127.0.0.1:9000step-ca, ACME directory at /acme/acme/directory
app.lab.internal:80, :443Caddy, ACME client and reverse proxy
nas.lab.internal:443, added laterSecond name on the same Caddy site, used for the wrong-name test
(no name)127.0.0.1:8080python3 http.server, the app
(no name)127.0.0.1:8443, 8444, 8445openssl s_server test listeners: the app leaf, the www.example.com test, and old.lab.internal

One line in the container’s /etc/hosts maps the three lab names to 127.0.0.1. I put the file back at teardown. I used .internal because ICANN reserved it in July 2024 for private use, so it will never be delegated in the public DNS root.

Results

TestClient error, exactCauseFix
Global acme_ca, .internal namenone; issuer Caddy Local Authority - ECC IntermediateCaddy uses its local CA for non-public namestls { ca ... } on the site
Caddy to step-ca, no rootx509: certificate signed by unknown authorityACME client did not trust step-ca’s HTTPSca_root root_ca.crt
Name Caddy has no site fortlsv1 alert internal error (curl exit 35)no certificate for that SNIadd the name to the site
Leaf served without intermediateunable to get local issuer certificates_server -cert sent only the first PEM-cert_chain chain.crt
Wrong name on a single-cert serverno alternative certificate subject name matches target hostname 'nas.lab.internal'name not in SANissue a certificate with that name
By IPno alternative certificate subject name matches target ipv4 address '127.0.0.1'no IP SANuse the name, or add an IP SAN
Root not trustedunable to get local issuer certificate (OpenSSL), certificate signed by unknown authority (Go)root not in trust storeinstall root
Name outside labdns name "www.example.com" not allowedissuance policyintended
Cert past notAftercertificate has expiredexpiredrenew earlier
Renew after expirycertificate expired on 2026-11-30 10:57:18 +0000 UTC (401)/renew needs a valid certre-issue via provisioner
Caddy 6-minute certs, default scancertificate has expired for about 5 minutesrenew_interval 10mrenew_interval 1m, then a full restart
renew_interval 1m applied by reloadcertificate has expired again from 11:12:46 UTCreload kept the old maintenance loopstop and start Caddy
6-minute certs, 1-minute scannone; new certificate every minute per nameeach fresh cert already in Caddy’s emergency windowlonger lifetimes; not tested

The lesson I keep relearning: two different faults print unable to get local issuer certificate. Look at what the server sent with -showcerts before you touch the trust store.

On a real network:

Keep the root key offline after init and run step-ca with the intermediate only. Add Name Constraints to the CA certificates when you create them, plus an issuance policy, so a leaked key cannot mint certificates for your bank. Protect the JWK provisioner password like a root password, because in this lab it could sign any name until the policy went in. Distribute the root through your configuration management, not by hand, and write down every machine and app store you put it in, so you can take it out again.

About the P-256 key in this lab:

This lab’s CA keys are ECDSA P-256, as the step output in Part 6 shows. Chrome says that as of March 15, 2027 it intends to stop trusting CA keys that use ECDSA P-256. For a throwaway lab CA that is fine. For a CA you plan to keep, choose a key type other than P-256 when you create it. As of December 5, 2026, no break of P-256 has been published.

What I did not test

No browser or Java trust store, no X.509 Name Constraints, no tls-alpn-01 or dns-01, no revocation, and no lifetime between five minutes and 24 hours. The full list is at the end of the Go deeper section.

Sources

Go deeper: run the lab

What you will build

  • A two-tier CA with step-ca: a root, an intermediate, a JWK admin provisioner, and an ACME provisioner, listening on ca.lab.internal:9000
  • Caddy in front of a tiny Python web app, ordering its certificate from step-ca over ACME with the http-01 challenge
  • A verified chain from curl, OpenSSL and Python
  • Six failures with the exact client error for each, and the fix that cleared it
  • An issuance policy that stops the CA from signing names outside *.lab.internal
  • A teardown that leaves the trust store byte-for-byte as it started

Prerequisites

Parts and cost:

  • One Linux host or VM with root, or a throwaway container. I used a debian:trixie container on a VPS with 4 vCPU and 15.6 GB RAM. I did not measure the lab’s memory use. Host load stayed near zero, as the teardown section shows.
  • Cost: $0. step-ca, the step CLI and Caddy are free, open source, single binaries.

Access:

  • Ports 80 and 443 free. Caddy binds both, so it runs as root here. In the container everything already runs as root, so the commands below have no sudo. On a normal host, add sudo to the Caddy, /etc/hosts and trust store steps.
  • Permission to edit /etc/hosts and the system trust store, and to put both back.

Required knowledge:

  • Comfortable reading curl -v output
  • You know what a TLS certificate is and that a browser checks the name
Versions in this run:

step-ca 0.30.2 (release date 2026-03-23), step CLI 0.31.0 (2026-09-25), Caddy 2.11.9, all from the official GitHub releases and checked against their release checksum files. OpenSSL 3.5.9, curl 8.14.1 and Python 3.13.5 came from Debian inside the container. PID 1 is docker-init, there is no systemd, and every daemon below is started by hand with nohup. On a normal host you would write a unit file instead.

How to read the output:

Every output block is a byte-for-byte excerpt of a log captured on bn-dev during this run. Each block starts with the command as it ran, after the $ prompt my logging wrapper printed. The wrapper also printed an exit status after each command, a label for commands it started in the background, and a header line at the top of each renewal watch. I cut those lines, along with the lines my own echo checks printed, so the blocks hold only commands and their output. A line that reads ... marks every place I cut whole lines, including those, curl’s boilerplate help text and TLS handshake chatter. Where an exit code matters, I give it in the prose. No line inside a block is shortened or edited. A ... inside a line, as in the step CLI’s [Serial: 2996...1308], is the tool’s own output. A few lines end early because the command I logged piped through cut -c, and I say so where it matters. The only redaction was the container’s Docker bridge address, which I replaced with a marker in the environment check at the start. In prose I write it as [REDACTED].

Part 1: install pinned binaries and check them

Download the release tarballs and the checksum files from the same release, then check them before you unpack anything.

bash
B=https://github.com
curl -fsSLO $B/smallstep/certificates/releases/download/v0.30.2/step-ca_linux_0.30.2_amd64.tar.gz
curl -fsSL -o step-ca-checksums.txt $B/smallstep/certificates/releases/download/v0.30.2/checksums.txt
curl -fsSLO $B/smallstep/cli/releases/download/v0.31.0/step_linux_0.31.0_amd64.tar.gz
curl -fsSL -o step-cli-checksums.txt $B/smallstep/cli/releases/download/v0.31.0/checksums.txt
curl -fsSLO $B/caddyserver/caddy/releases/download/v2.11.9/caddy_2.11.9_linux_amd64.tar.gz
curl -fsSLO $B/caddyserver/caddy/releases/download/v2.11.9/caddy_2.11.9_checksums.txt

grep ' step-ca_linux_0.30.2_amd64.tar.gz$' step-ca-checksums.txt | sha256sum -c -
grep ' step_linux_0.31.0_amd64.tar.gz$' step-cli-checksums.txt | sha256sum -c -
grep ' caddy_2.11.9_linux_amd64.tar.gz$' caddy_2.11.9_checksums.txt | sha512sum -c -

The checksum check on all three downloads:

$ cd dl && grep ' step-ca_linux_0.30.2_amd64.tar.gz$' step-ca-checksums.txt | sha256sum -c - && grep ' step_linux_0.31.0_amd64.tar.gz$' step-cli-checksums.txt | sha256sum -c - && grep ' caddy_2.11.9_linux_amd64.tar.gz$' caddy_2.11.9_checksums.txt | sha512sum -c -
step-ca_linux_0.30.2_amd64.tar.gz: OK
step_linux_0.31.0_amd64.tar.gz: OK
caddy_2.11.9_linux_amd64.tar.gz: OK
...

Caddy publishes SHA-512 sums, smallstep publishes SHA-256. The SHA-256 values from this run match the ones I recorded on November 21 on a different machine:

$ cd dl && sha256sum step-ca_linux_0.30.2_amd64.tar.gz step_linux_0.31.0_amd64.tar.gz caddy_2.11.9_linux_amd64.tar.gz
126615795bafe3f2d3f890e2d628fa6e2857315fb48d0671d34b23047cc37d73  step-ca_linux_0.30.2_amd64.tar.gz
a7e13726efa8782f3d5459174dacf602ab3514b9431f2d42a6a75950b7685e5f  step_linux_0.31.0_amd64.tar.gz
5b8cb7faf8726a2028ad96a66e54e6e81e8f361bc6175e5d22bbd997cc5177fb  caddy_2.11.9_linux_amd64.tar.gz
...

A checksum file from the same release only proves the download was not corrupted. Both projects also ship sigstore or cosign signatures for stronger proof. I did not verify those signatures in this run. If you want the longer version of why that matters, it is its own note.

I installed the three binaries into /opt/lab-stepca/bin so teardown is one rm -rf:

$ step-ca version; step version; caddy version
Smallstep CA/0.30.2 (linux/amd64)
Release Date: 2026-03-23T00:18:00Z
Smallstep CLI/0.31.0 (linux/amd64)
Release Date: 2026-09-25T19:53:51Z
v2.11.9 h1:bhZtcRKQOq0fuLvEgCdPYvUxXyGn9kzjG4lh2332DTE=
...

Part 2: create the CA and turn on ACME

Keep the whole PKI in one directory with STEPPATH, and keep the password in a file with mode 600. For the lab I used /tmp/lab-stepca.

bash
export STEPPATH=/tmp/lab-stepca/step
mkdir -p /tmp/lab-stepca && chmod 700 /tmp/lab-stepca
head -c 24 /dev/urandom | base64 > /tmp/lab-stepca/ca-password
chmod 600 /tmp/lab-stepca/ca-password
cp /etc/hosts /tmp/hosts.pre-stepca-lab
echo '127.0.0.1 ca.lab.internal app.lab.internal nas.lab.internal # stepca-lab' | tee -a /etc/hosts

step ca init --deployment-type standalone --name 'BytesNation Lab CA' \
  --dns ca.lab.internal --address 127.0.0.1:9000 \
  --provisioner admin@lab.internal \
  --password-file /tmp/lab-stepca/ca-password --acme

The hosts line, and the names resolving:

$ cp /etc/hosts /tmp/hosts.pre-stepca-lab && echo '127.0.0.1 ca.lab.internal app.lab.internal nas.lab.internal # stepca-lab' | tee -a /etc/hosts && getent hosts ca.lab.internal app.lab.internal nas.lab.internal
127.0.0.1 ca.lab.internal app.lab.internal nas.lab.internal # stepca-lab
127.0.0.1       ca.lab.internal app.lab.internal nas.lab.internal
127.0.0.1       ca.lab.internal app.lab.internal nas.lab.internal
127.0.0.1       ca.lab.internal app.lab.internal nas.lab.internal
...

step ca init prints its summary with color codes, so I show the plain lines and the files it wrote instead:

$ step ca init --deployment-type standalone --name 'BytesNation Lab CA' --dns ca.lab.internal --address 127.0.0.1:9000 --provisioner admin@lab.internal --password-file /tmp/lab-stepca/ca-password --acme
...
Generating root certificate... done!
Generating intermediate certificate... done!
...
Your PKI is ready to go. To generate certificates for individual services see 'step help ca'.
...
$ find $STEPPATH -type f | sort; cat $STEPPATH/config/ca.json | sed 's/"encryptedKey": "[^"]*"/"encryptedKey": "REDACTED"/'
/tmp/lab-stepca/step/certs/intermediate_ca.crt
/tmp/lab-stepca/step/certs/root_ca.crt
/tmp/lab-stepca/step/config/ca.json
/tmp/lab-stepca/step/config/defaults.json
/tmp/lab-stepca/step/secrets/intermediate_ca_key
/tmp/lab-stepca/step/secrets/root_ca_key
...

--acme adds a second provisioner named acme next to the JWK admin one. A provisioner is step-ca’s word for “a way to prove you may get a certificate”. JWK uses a password-protected key. ACME uses the challenges from RFC 8555. The authority block of the generated ca.json, from the same log, with the encrypted key replaced by sed before it was printed:

	"authority": {
		"provisioners": [
			{
				"type": "JWK",
				"name": "admin@lab.internal",
				"key": {
					"use": "sig",
					"kty": "EC",
					"kid": "BODWFpZfPwLwOcpg3jxI-NR6x3cYuondYH3BYooDcQQ",
					"crv": "P-256",
					"alg": "ES256",
					"x": "NUp3DxOuGR6N_B02AR2tU0hS83WABmt7MZmzQHnNJuU",
					"y": "xlsN83MlgAjmAN2bY80n0OnI9YSLFaeIupF3EhLGj5k"
				},
				"encryptedKey": "REDACTED"
			},
			{
				"type": "ACME",
				"name": "acme"
			}
		]
	},

Look at what you just made before you trust it:

$ openssl x509 -in $STEPPATH/certs/root_ca.crt -noout -subject -dates -ext basicConstraints,keyUsage,nameConstraints; openssl x509 -in $STEPPATH/certs/intermediate_ca.crt -noout -subject -issuer -dates -ext basicConstraints,keyUsage
subject=O=BytesNation Lab CA, CN=BytesNation Lab CA Root CA
notBefore=Nov 30 10:55:20 2026 GMT
notAfter=Nov 27 10:55:20 2036 GMT
X509v3 Key Usage: critical
    Certificate Sign, CRL Sign
X509v3 Basic Constraints: critical
    CA:TRUE, pathlen:1
subject=O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
issuer=O=BytesNation Lab CA, CN=BytesNation Lab CA Root CA
notBefore=Nov 30 10:55:21 2026 GMT
notAfter=Nov 27 10:55:21 2036 GMT
X509v3 Key Usage: critical
    Certificate Sign, CRL Sign
X509v3 Basic Constraints: critical
    CA:TRUE, pathlen:0
...

Three things stand out. The root is good for ten years. pathlen:1 means the root allows one intermediate below it, and the intermediate has pathlen:0, so it can sign only end-entity certificates. And the Name Constraints extension I asked OpenSSL to print is not there. This root can sign a certificate for any name on earth. Part 6 comes back to that.

Both private keys sit in secrets/ with mode 600:

$ ls -l $STEPPATH/secrets
total 8
-rw------- 1 root root 314 Nov 30 05:55 intermediate_ca_key
-rw------- 1 root root 314 Nov 30 05:55 root_ca_key
...

In a real homelab the root key belongs offline after init. Here it stays on disk because the container is deleted an hour later.

Start the CA and check it:

$ nohup step-ca $STEPPATH/config/ca.json --password-file /tmp/lab-stepca/ca-password > /lab/logs/step-ca.log 2>&1 &
...
$ cat /lab/logs/step-ca.log
...
2026/11/30 05:55:21 Starting Smallstep CA/0.30.2 (linux/amd64)
...
2026/11/30 05:55:21 X.509 Root Fingerprint: 8c012958b04238074df334d4b7a77637cf5f8b4cd6d0fe5b201e2305b5a1d99a
2026/11/30 05:55:21 Serving HTTPS on 127.0.0.1:9000 ...
...
$ step ca health --ca-url https://ca.lab.internal:9000 --root $STEPPATH/certs/root_ca.crt
ok
...
$ curl -s --cacert $STEPPATH/certs/root_ca.crt https://ca.lab.internal:9000/acme/acme/directory; echo
{"newNonce":"https://ca.lab.internal:9000/acme/acme/new-nonce","newAccount":"https://ca.lab.internal:9000/acme/acme/new-account","newOrder":"https://ca.lab.internal:9000/acme/acme/new-order","revokeCert":"https://ca.lab.internal:9000/acme/acme/revoke-cert","keyChange":"https://ca.lab.internal:9000/acme/acme/key-change"}

...

That JSON is the ACME directory from RFC 8555 section 7.1.1. Any ACME client can start from that URL. The same curl without --cacert already fails, which is a preview of Part 6:

Recorded on bn-dev, Nov 30, 2026: curl fails against step-ca 0.30.2 until it gets the lab root, first with --cacert and then from the system store.Prefer text? Read the same output below
$ curl -sS https://ca.lab.internal:9000/health
curl: (60) SSL certificate problem: unable to get local issuer certificate
...

Part 3: point Caddy at step-ca, and the two ways it went wrong first

The app is one line of HTML behind python3 -m http.server 8080 --bind 127.0.0.1:

$ cd /tmp/lab-stepca/www && nohup python3 -m http.server 8080 --bind 127.0.0.1 > /lab/logs/app.log 2>&1 &
...
$ curl -sS http://127.0.0.1:8080/
hello from app.lab.internal (BytesNation step-ca lab)
...

What broke first: Caddy used its own CA and said nothing

My first Caddyfile set the ACME directory globally:

$ cat Caddyfile.v1-no-root
{
	acme_ca https://ca.lab.internal:9000/acme/acme/directory
	email admin@lab.internal
	skip_install_trust
	storage file_system /tmp/lab-stepca/caddy
	admin 127.0.0.1:2019
}

app.lab.internal {
	reverse_proxy 127.0.0.1:8080
}
...

Caddy started clean and logged success:

$ grep -E 'error|obtain|x509|certificate' /lab/logs/caddy-v1.log | head -20
...
{"level":"info","ts":1796036126.5072944,"logger":"tls.obtain","msg":"acquiring lock","identifier":"app.lab.internal"}
{"level":"info","ts":1796036126.5083184,"logger":"tls.obtain","msg":"lock acquired","identifier":"app.lab.internal"}
{"level":"info","ts":1796036126.5083728,"logger":"tls.obtain","msg":"obtaining certificate","identifier":"app.lab.internal"}
{"level":"info","ts":1796036126.5272686,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"app.lab.internal","issuer":"local"}
{"level":"info","ts":1796036126.527327,"logger":"tls.obtain","msg":"releasing lock","identifier":"app.lab.internal"}
...

Read the issuer field on the certificate obtained successfully line. local is Caddy’s built-in CA, not step-ca. The served certificate confirmed it:

$ echo | openssl s_client -connect 127.0.0.1:443 -servername app.lab.internal 2>/dev/null | openssl x509 -noout -subject -issuer -ext subjectAltName -dates
subject=
issuer=CN=Caddy Local Authority - ECC Intermediate
X509v3 Subject Alternative Name: critical
    DNS:app.lab.internal
notBefore=Nov 30 10:55:26 2026 GMT
notAfter=Nov 30 22:55:26 2026 GMT
...

step-ca’s log showed no request from Caddy. The only ACME line in it at that point was my own curl from Part 2, at 05:55:24, two seconds before Caddy started. I checked that afterwards against the full step-ca log:

$ grep -c 'acme' /lab/logs/step-ca.log
1
...
$ grep -E 'method=|certificate=' /lab/logs/step-ca.log | sed -n '2,12p' | grep -oE '^time="[^"]+"|method=[A-Z]+|path=[^ ]+|status=[0-9]+|user-agent="[^"]+"' | paste -sd' ' | sed 's/ time=/\ntime=/g'
time="2026-11-30T05:55:24-05:00" method=GET path=/acme/acme/directory status=200
...

Caddy’s docs say names under .internal, .local, .localhost and .home.arpa do not qualify for publicly trusted certificates, and Caddy serves those from its local CA. In this run the global acme_ca did not change that. No error, no warning, just a certificate from a CA you did not mean to run. If I had installed my step-ca root on the clients, they would have rejected this certificate and I would have blamed the clients.

The fix is to name the issuer on the site itself.

What broke second: Caddy did not trust step-ca

$ diff Caddyfile.v1-no-root Caddyfile.v2-acme-no-root
2d1
< 	acme_ca https://ca.lab.internal:9000/acme/acme/directory
9a9,11
> 	tls {
> 		ca https://ca.lab.internal:9000/acme/acme/directory
> 	}
...

Now Caddy did talk to step-ca, and failed. The last error lines, each cut at 700 characters by my logging command:

$ grep -E 'tls.obtain|tls.issuance|error' /lab/logs/caddy-v2.log | cut -c1-700 | head -12
...
{"level":"warn","ts":1796036135.6065142,"logger":"http.acme_client","msg":"HTTP request failed; retrying","url":"https://ca.lab.internal:9000/acme/acme/directory","error":"performing request: Get \"https://ca.lab.internal:9000/acme/acme/directory\": tls: failed to verify certificate: x509: certificate signed by unknown authority"}
{"level":"warn","ts":1796036135.8587563,"logger":"http.acme_client","msg":"HTTP request failed; retrying","url":"https://ca.lab.internal:9000/acme/acme/directory","error":"performing request: Get \"https://ca.lab.internal:9000/acme/acme/directory\": tls: failed to verify certificate: x509: certificate signed by unknown authority"}
{"level":"warn","ts":1796036136.110792,"logger":"http.acme_client","msg":"HTTP request failed; retrying","url":"https://ca.lab.internal:9000/acme/acme/directory","error":"performing request: Get \"https://ca.lab.internal:9000/acme/acme/directory\": tls: failed to verify certificate: x509: certificate signed by unknown authority"}
{"level":"error","ts":1796036136.110972,"logger":"tls.obtain","msg":"could not get certificate from issuer","identifier":"app.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory","error":"registering account [mailto:admin@lab.internal] with server: provisioning client: performing request: Get \"https://ca.lab.internal:9000/acme/acme/directory\": tls: failed to verify certificate: x509: certificate signed by unknown authority"}
{"level":"error","ts":1796036136.1109896,"logger":"tls.obtain","msg":"will retry","error":"[app.lab.internal] Obtain: registering account [mailto:admin@lab.internal] with server: provisioning client: performing request: Get \"https://ca.lab.internal:9000/acme/acme/directory\": tls: failed to verify certificate: x509: certificate signed by unknown authority","attempt":1,"retrying_in":60,"elapsed":0.51960063,"max_duration":2592000}
...

step-ca saw the other side of the same failure:

$ tail -n +$(($(cat /tmp/lab-stepca/step-ca.mark)+1)) /lab/logs/step-ca.log | cut -c1-300 | head -8
2026/11/30 05:55:35 net/http/server.go:3648: http: TLS handshake error from 127.0.0.1:47250: remote error: tls: bad certificate
2026/11/30 05:55:35 net/http/server.go:3648: http: TLS handshake error from 127.0.0.1:47260: remote error: tls: bad certificate
2026/11/30 05:55:36 net/http/server.go:3648: http: TLS handshake error from 127.0.0.1:47270: remote error: tls: bad certificate
...

The ACME client is a TLS client too. step-ca serves its directory over HTTPS with a certificate from its own intermediate, and Caddy did not have the root. The fix is one line:

$ diff Caddyfile.v2-acme-no-root Caddyfile.v3-single-name
10a11
> 		ca_root /tmp/lab-stepca/step/certs/root_ca.crt
...

The issuance that worked

Caddy’s log, with the lock and account lines cut:

$ grep -E 'tls.obtain|tls.issuance|acme_client|error' /lab/logs/caddy-v3.log | cut -c1-600
...
{"level":"info","ts":1796036146.6268945,"logger":"tls.obtain","msg":"obtaining certificate","identifier":"app.lab.internal"}
...
{"level":"info","ts":1796036146.6460497,"logger":"http.acme_client","msg":"trying to solve challenge","identifier":"app.lab.internal","challenge_type":"http-01","ca":"https://ca.lab.internal:9000/acme/acme/directory"}
{"level":"info","ts":1796036146.9055252,"logger":"http.acme_client","msg":"authorization finalized","identifier":"app.lab.internal","authz_status":"valid"}
{"level":"info","ts":1796036146.9055555,"logger":"http.acme_client","msg":"validations succeeded; finalizing order","order":"https://ca.lab.internal:9000/acme/acme/order/pmC7idzLw5Lr4dmMqMi7LGyFxPZhuzPG"}
{"level":"info","ts":1796036146.9132752,"logger":"http.acme_client","msg":"successfully downloaded available certificate chains","count":1,"first_url":"https://ca.lab.internal:9000/acme/acme/certificate/W4U2Yw1bzB28aeCvAw1VP5QtIYppG4nq"}
{"level":"info","ts":1796036146.9157345,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"app.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory"}
...

From obtaining certificate at ts 1796036146.6268945 to certificate obtained successfully at 1796036146.9157345 took 0.29 seconds. step-ca’s log shows the RFC 8555 sequence in order. I pulled the method, path, status and user agent out of each request line afterwards:

$ grep -E 'method=|certificate=' /lab/logs/step-ca.log | sed -n '2,12p' | grep -oE '^time="[^"]+"|method=[A-Z]+|path=[^ ]+|status=[0-9]+|user-agent="[^"]+"' | paste -sd' ' | sed 's/ time=/\ntime=/g'
...
time="2026-11-30T05:55:46-05:00" method=GET path=/acme/acme/directory status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=HEAD path=/acme/acme/new-nonce status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/new-account status=201 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/new-order status=201 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/authz/7EXxeGjlpfgD997m0wNxBLGeuBbGbGSl status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/challenge/7EXxeGjlpfgD997m0wNxBLGeuBbGbGSl/UOLuKFYDS6sjKKJPdkWZ0X0BkEmQUfvn status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/authz/7EXxeGjlpfgD997m0wNxBLGeuBbGbGSl status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/order/pmC7idzLw5Lr4dmMqMi7LGyFxPZhuzPG/finalize status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
time="2026-11-30T05:55:46-05:00" method=POST path=/acme/acme/certificate/W4U2Yw1bzB28aeCvAw1VP5QtIYppG4nq status=200 user-agent="Caddy/2.11.9 CertMagic acmez (linux; amd64)"
...

Between the challenge POST and the finalize, step-ca fetched the token from Caddy on port 80. Caddy logged serving it:

$ grep -E 'key authentication|challenge' /lab/logs/caddy-v3.log | head -4 | cut -c1-400
{"level":"info","ts":1796036146.6460497,"logger":"http.acme_client","msg":"trying to solve challenge","identifier":"app.lab.internal","challenge_type":"http-01","ca":"https://ca.lab.internal:9000/acme/acme/directory"}
{"level":"info","ts":1796036146.6498644,"logger":"http","msg":"served key authentication","identifier":"app.lab.internal","challenge":"http-01","remote":"127.0.0.1:42438","distributed":false}
...

That is why the CA must be able to resolve app.lab.internal and reach it.

Part 4: verify the chain

The chain Caddy served, as OpenSSL saw it:

$ echo | openssl s_client -connect 127.0.0.1:443 -servername app.lab.internal -showcerts 2>/dev/null | grep -E '^ *[0-9] s:|^ +i:|a:PKEY|v:NotBefore'
 0 s:
   i:O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
   a:PKEY: EC, (prime256v1); sigalg: ecdsa-with-SHA256
   v:NotBefore: Nov 30 10:54:46 2026 GMT; NotAfter: Dec  1 10:55:46 2026 GMT
 1 s:O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
   i:O=BytesNation Lab CA, CN=BytesNation Lab CA Root CA
   a:PKEY: EC, (prime256v1); sigalg: ecdsa-with-SHA256
   v:NotBefore: Nov 30 10:55:21 2026 GMT; NotAfter: Nov 27 10:55:21 2036 GMT
...

Caddy sends two certificates, the leaf and the intermediate. It does not send the root. The client must already have it.

The leaf itself:

$ echo | openssl s_client -connect 127.0.0.1:443 -servername app.lab.internal 2>/dev/null | openssl x509 -noout -subject -issuer -serial -dates -ext subjectAltName,keyUsage,extendedKeyUsage,authorityKeyIdentifier
subject=
issuer=O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
serial=3D088F27415A2B624F3EAFD6E485F0F3
notBefore=Nov 30 10:54:46 2026 GMT
notAfter=Dec  1 10:55:46 2026 GMT
X509v3 Key Usage: critical
    Digital Signature
X509v3 Extended Key Usage: 
    TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Authority Key Identifier: 
    2D:1F:63:DC:B9:3A:10:58:2F:0C:DB:9B:4D:BF:E8:46:31:31:58:C6
X509v3 Subject Alternative Name: critical
    DNS:app.lab.internal
...

The subject is empty and the SAN is marked critical. RFC 5280 section 4.2.1.6 requires that pairing. If the subject is empty, the SAN extension must be critical. The name lives only in the SAN, which is the only place modern clients look. The lifetime is 24 hours plus one minute. step-ca’s log shows the certificate was signed at 05:55:46 ET, which is 10:55:46 UTC, and notBefore sits one minute earlier, so step-ca backdated it. smallstep documents the 24-hour default TLS lifetime in its configuration docs. Short-lived certificates are the point of running ACME. Part 7 shows what happens when renewal lags.

curl, given the root explicitly:

$ curl -v --cacert $STEPPATH/certs/root_ca.crt https://app.lab.internal/ 2>&1 | grep -vE '^> (User-Agent|Accept)|^\{|^\} \['
...
*  CAfile: /tmp/lab-stepca/step/certs/root_ca.crt
*  CApath: /etc/ssl/certs
...
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519MLKEM768 / id-ecPublicKey
* ALPN: server accepted h2
* Server certificate:
*  subject: 
*  start date: Nov 30 10:54:46 2026 GMT
*  expire date: Dec  1 10:55:46 2026 GMT
*  subjectAltName: host "app.lab.internal" matched cert's "app.lab.internal"
*  issuer: O=BytesNation Lab CA; CN=BytesNation Lab CA Intermediate CA
*  SSL certificate verify ok.
*   Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA256
*   Certificate level 1: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA256
*   Certificate level 2: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA256
...
< HTTP/2 200 
...
< server: SimpleHTTP/0.6 Python/3.13.5
< via: 1.0 Caddy
...
hello from app.lab.internal (BytesNation step-ca lab)
...

Two lines do the work. subjectAltName: host "app.lab.internal" matched is the name check. SSL certificate verify ok is the chain check. Level 2 is the root from --cacert, so the client built the full path from leaf to root. One more detail. curl and Caddy negotiated X25519MLKEM768, the hybrid post-quantum key exchange. I did not configure that.

OpenSSL agrees, with the hostname check turned on:

$ echo | openssl s_client -connect app.lab.internal:443 -servername app.lab.internal -CAfile $STEPPATH/certs/root_ca.crt -verify_hostname app.lab.internal 2>&1 | grep -E 'depth=|verify return|Verification|Verified peername|Protocol|Cipher is'
depth=2 O=BytesNation Lab CA, CN=BytesNation Lab CA Root CA
...
depth=1 O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
...
depth=0 
...
Verification: OK
Verified peername: app.lab.internal
...

Part 5: the wrong name

nas.lab.internal was already in /etc/hosts, pointing at the same Caddy, but it was not in the Caddyfile. I asked for it anyway:

$ curl -sS --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://nas.lab.internal/ ; echo
curl: (35) TLS connect error: error:0A000438:SSL routines::tlsv1 alert internal error

...
$ curl -sS --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://127.0.0.1/ ; echo
curl: (35) TLS connect error: error:0A000438:SSL routines::tlsv1 alert internal error

...

That is not a SAN error. Caddy picks a certificate by the SNI name in the client hello, finds none, and aborts the handshake with a TLS alert. You never see a certificate, so you cannot check its names. If you get exit code 35 with alert internal error from Caddy, check whether the site block lists the name you typed.

To see a real name mismatch, you need a server that hands out one certificate whatever you ask for. Many appliances with one uploaded certificate work that way. I copied the ACME leaf out of Caddy’s storage and served it with openssl s_server.

Unplanned: the chain was missing its intermediate

$ cd /tmp/lab-stepca/single && openssl s_server -accept 127.0.0.1:8443 -cert app.lab.internal.crt -key app.lab.internal.key -www -quiet &
...
$ curl -sS -o /dev/null --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://app.lab.internal:8443/ && echo 'app.lab.internal:8443 OK'
curl: (60) SSL certificate problem: unable to get local issuer certificate
...

The right name, the right root, and still a failure. The file held two certificates, leaf and intermediate, but s_server -cert sends only the first one:

$ grep -c 'BEGIN CERTIFICATE' /tmp/lab-stepca/single/app.lab.internal.crt
2
...
$ echo | openssl s_client -connect 127.0.0.1:8443 -showcerts 2>/dev/null | grep -E '^ *[0-9] s:|^ +i:'
 0 s:
   i:O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
...

The client holds the root but has no way to get from the leaf to it. curl prints the same string you get when the root is missing, so the error alone will not tell you which problem you have. -showcerts will. The fix is to split the intermediate out and pass it with -cert_chain.

That fix did not work the first time either, and the reason was my own script. I killed the old listener by the PID I had saved, and the saved PID was wrong, so the old listener kept port 8443. The new s_server failed to bind and exited, and -showcerts still listed one certificate. The listener’s own log and ss show it:

$ cat /lab/logs/s_server-8443.log
8047DBCF80790000:error:80000062:system library:BIO_bind:Address already in use:../crypto/bio/bio_sock2.c:237:calling bind()
8047DBCF80790000:error:10000075:BIO routines:BIO_bind:unable to bind socket:../crypto/bio/bio_sock2.c:239:
...
$ ss -ltnp '( sport = :8443 )'
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess                           
LISTEN 0      4096       127.0.0.1:8443      0.0.0.0:*    users:(("openssl",pid=3946,fd=3))
...

So every 8443 result in that first run after the restart is still the chain-less listener, and I did not use them. I killed it by its command line and started the fixed one. My pkill -f pattern also matched the shell that ran it, which is why that command printed nothing and was killed with exit status 143. Rerun at 05:58 ET:

$ cd /tmp/lab-stepca/single && openssl s_server -accept 127.0.0.1:8443 -cert app.lab.internal.crt -cert_chain chain.crt -key app.lab.internal.key -www -quiet &
...
$ ss -ltnp '( sport = :8443 )'
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess                           
LISTEN 0      4096       127.0.0.1:8443      0.0.0.0:*    users:(("openssl",pid=8291,fd=3))
...
$ echo | openssl s_client -connect 127.0.0.1:8443 -showcerts 2>/dev/null | grep -E '^ *[0-9] s:|^ +i:'
 0 s:
   i:O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
 1 s:O=BytesNation Lab CA, CN=BytesNation Lab CA Intermediate CA
   i:O=BytesNation Lab CA, CN=BytesNation Lab CA Root CA
...
$ curl -sS --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://app.lab.internal:8443/ | head -3
<HTML><BODY BGCOLOR="#ffffff">
<pre>

...

Both certificates now, and https://app.lab.internal:8443/ returned the s_server status page. Check the listener with ss after a restart, not just your PID file.

The real SAN mismatch

Same server, same certificate, a name that is not on it:

$ curl -v -o /dev/null --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://nas.lab.internal:8443/ 2>&1 | grep -E 'subjectAltName|SSL:|curl:|issuer:'
*  subjectAltName does not match hostname nas.lab.internal
* SSL: no alternative certificate subject name matches target hostname 'nas.lab.internal'
curl: (60) SSL: no alternative certificate subject name matches target hostname 'nas.lab.internal'
...
$ curl -sS -o /dev/null --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://127.0.0.1:8443/
curl: (60) SSL: no alternative certificate subject name matches target ipv4 address '127.0.0.1'
...

The same failure from OpenSSL and Python:

$ echo | openssl s_client -connect 127.0.0.1:8443 -CAfile /tmp/lab-stepca/step/certs/root_ca.crt -verify_hostname nas.lab.internal 2>&1 | grep -E 'verify error|Verification|Verify return code'
verify error:num=62:hostname mismatch
Verification error: hostname mismatch
Verify return code: 62 (hostname mismatch)
...
$ python3 -c "import ssl,socket; c=ssl.create_default_context(cafile='/tmp/lab-stepca/step/certs/root_ca.crt'); s=c.wrap_socket(socket.create_connection(('127.0.0.1',8443)), server_hostname='nas.lab.internal')" 2>&1 | tail -1
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'nas.lab.internal'. (_ssl.c:1029)
...

The chain was fine. The name was not. Browsing to a homelab box by IP fails the same way unless the certificate carries that IP as an IP SAN.

The fix on Caddy was to put the second name on the site:

$ diff Caddyfile.v3-single-name Caddyfile.v4-nas-added
8c8
< app.lab.internal {
---
> app.lab.internal, nas.lab.internal {
...
$ caddy reload --config Caddyfile.v4-nas-added --adapter caddyfile --address 127.0.0.1:2019 2>&1 | grep -v '^{"level":"info"' ; echo reloaded
...
$ tail -n +37 /lab/logs/caddy-v3.log | grep -E 'tls.obtain|acme_client|error' | cut -c1-300
...
{"level":"info","ts":1796036160.0161014,"logger":"tls.obtain","msg":"obtaining certificate","identifier":"nas.lab.internal"}
...
{"level":"info","ts":1796036160.2979932,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"nas.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory"}
...

caddy reload triggered a second ACME order, and step-ca signed it in 0.28 seconds, from ts 1796036160.0161014 to 1796036160.2979932. Caddy issues one certificate per name. It does not add the name to the existing certificate. Storage afterwards held two files:

$ find /tmp/lab-stepca/caddy/certificates -name '*.crt' | sort
/tmp/lab-stepca/caddy/certificates/ca.lab.internal-9000-acme-acme-directory/app.lab.internal/app.lab.internal.crt
/tmp/lab-stepca/caddy/certificates/ca.lab.internal-9000-acme-acme-directory/nas.lab.internal/nas.lab.internal.crt
...
$ curl -v -o /dev/null --cacert /tmp/lab-stepca/step/certs/root_ca.crt https://nas.lab.internal/ 2>&1 | grep -E 'subjectAltName|issuer:|verify ok'
*  subjectAltName: host "nas.lab.internal" matched cert's "nas.lab.internal"
*  issuer: O=BytesNation Lab CA; CN=BytesNation Lab CA Intermediate CA
*  SSL certificate verify ok.
...

Part 6: the root is not in the trust store

Every check so far passed the root by hand. Drop --cacert and every client in the container fails:

$ curl -v -o /dev/null https://app.lab.internal/ 2>&1 | grep -E 'CAfile|CApath|SSL certificate|curl:'
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* SSL certificate problem: unable to get local issuer certificate
curl: (60) SSL certificate problem: unable to get local issuer certificate
...
$ echo | openssl s_client -connect 127.0.0.1:443 -servername app.lab.internal -verify_return_error 2>&1 | grep -E 'verify error|Verify return code|alert'
verify error:num=20:unable to get local issuer certificate
Verify return code: 20 (unable to get local issuer certificate)
...
$ python3 -c "import ssl,urllib.request; urllib.request.urlopen('https://app.lab.internal/')" 2>&1 | tail -1
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1029)>
...
$ step certificate verify --host app.lab.internal /tmp/lab-stepca/single/app.lab.internal.crt 2>&1; echo
failed to verify certificate: x509: certificate signed by unknown authority

...

OpenSSL-based tools say unable to get local issuer certificate. Go-based tools such as step and Caddy say x509: certificate signed by unknown authority. Same fault, two dialects.

Before installing anything, I recorded the bundle so I could prove the rollback later:

$ sha256sum /etc/ssl/certs/ca-certificates.crt; grep -c "BEGIN CERT" /etc/ssl/certs/ca-certificates.crt
e9c7b63ee2623386e9b0a3ee32f499d01a8ea23dc83b8383ddff9f8e749543b7  /etc/ssl/certs/ca-certificates.crt
148
...

Then the fix:

$ step certificate install --all /tmp/lab-stepca/step/certs/root_ca.crt
Certificate /tmp/lab-stepca/step/certs/root_ca.crt has been installed.
X.509v3 Root CA Certificate (ECDSA P-256) [Serial: 1105...4417]
  Subject:     BytesNation Lab CA Root CA
  Issuer:      BytesNation Lab CA Root CA
  Valid from:  2026-11-30T10:55:20Z
          to:  2036-11-27T10:55:20Z
...
$ ls /usr/local/share/ca-certificates/; grep -c 'BEGIN CERT' /etc/ssl/certs/ca-certificates.crt; sha256sum /etc/ssl/certs/ca-certificates.crt
BytesNation_Lab_CA_Root_CA_110545153846565097045850672600281854417.crt
149
0ea436e01102dc1002c7a1e6aa276c390b189153f9844f31870f348ba1155e8e  /etc/ssl/certs/ca-certificates.crt
...

On Debian, step certificate install copies the root into /usr/local/share/ca-certificates/ and rebuilds the bundle. --all also tries the Firefox, Java and NSS stores. This container has no certutil or keytool, and root has no NSS database, so only the system store changed:

$ ls /root/.pki/nssdb 2>&1; command -v certutil keytool || echo 'no certutil/keytool in this container, so --all only changed the system store'
ls: cannot access '/root/.pki/nssdb': No such file or directory
...

I did not test a browser. If your browser keeps its own root store, the system store alone may not cover it.

$ curl -v https://app.lab.internal/ 2>&1 | grep -E 'CAfile|subjectAltName|issuer:|verify ok|^hello'
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  subjectAltName: host "app.lab.internal" matched cert's "app.lab.internal"
*  issuer: O=BytesNation Lab CA; CN=BytesNation Lab CA Intermediate CA
*  SSL certificate verify ok.
hello from app.lab.internal (BytesNation step-ca lab)
...
$ python3 -c "import urllib.request; print(urllib.request.urlopen('https://app.lab.internal/').read().decode().strip())"
hello from app.lab.internal (BytesNation step-ca lab)
...
$ step certificate verify --host app.lab.internal /tmp/lab-stepca/single/app.lab.internal.crt && echo 'step verify OK from system store'
...

What that trust buys an attacker

A root in the system store vouches for any name the CA will sign, including names you do not own. With the root installed, I asked the CA’s admin provisioner for a certificate it had no business signing. The output, with the colored status lines cut:

$ step ca certificate www.example.com /tmp/lab-stepca/example.crt /tmp/lab-stepca/example.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
$ step certificate inspect /tmp/lab-stepca/example.crt --short; grep -c 'BEGIN CERT' /tmp/lab-stepca/example.crt
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2502...4059]
  Subject:     www.example.com
  Issuer:      BytesNation Lab CA Intermediate CA
  Provisioner: admin@lab.internal [ID: BODW...DcQQ]
  Valid from:  2026-11-30T10:55:06Z
          to:  2026-12-01T10:56:06Z
2
...

Served with s_server -cert alone, it failed with the missing-intermediate error from Part 5:

$ curl -sS -o /dev/null --resolve www.example.com:8444:127.0.0.1 https://www.example.com:8444/
curl: (60) SSL certificate problem: unable to get local issuer certificate
...

My restart with -cert_chain then hit the same wrong-PID problem as on 8443, and the old listener kept 8444. I redid this part at 05:58 ET. By then the root was out of the store again and the policy below was already in place, so I first took the policy out of ca.json, reloaded step-ca and reinstalled the root:

$ diff <(python3 -m json.tool /tmp/lab-stepca/ca.json.with-policy) <(python3 -m json.tool $STEPPATH/config/ca.json)
44,53d43
<         "policy": {
<             "x509": {
<                 "allow": {
<                     "dns": [
<                         "*.lab.internal"
<                     ]
<                 },
<                 "allowWildcardNames": false
<             }
<         },
...
$ step certificate install --all /tmp/lab-stepca/step/certs/root_ca.crt
Certificate /tmp/lab-stepca/step/certs/root_ca.crt has been installed.
...
$ step ca certificate www.example.com /tmp/lab-stepca/example.crt /tmp/lab-stepca/example.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
$ cd /tmp/lab-stepca && openssl s_server -accept 127.0.0.1:8444 -cert example.crt -cert_chain example-chain.crt -key example.key -www -quiet &
...
$ ss -ltnp '( sport = :8444 )'
State  Recv-Q Send-Q Local Address:Port Peer Address:PortProcess                           
LISTEN 0      4096       127.0.0.1:8444      0.0.0.0:*    users:(("openssl",pid=9523,fd=3))
...
$ curl -v -o /dev/null --resolve www.example.com:8444:127.0.0.1 https://www.example.com:8444/ 2>&1 | grep -E 'CAfile|subjectAltName|issuer:|verify ok|HTTP/1'
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  subjectAltName: host "www.example.com" matched cert's "www.example.com"
*  issuer: O=BytesNation Lab CA; CN=BytesNation Lab CA Intermediate CA
*  SSL certificate verify ok.
* using HTTP/1.x
> GET / HTTP/1.1
< HTTP/1.0 200 ok
...

This container now trusted a homemade certificate for a domain I do not own, with no flags. Anyone who gets the admin provisioner password, or the intermediate key, can do the same to every machine that holds your root.

step-ca can refuse to sign names outside your lab. I added an issuance policy to ca.json and sent step-ca a SIGHUP to reload:

$ diff <(python3 -m json.tool /tmp/lab-stepca/ca.json.pre-policy) <(python3 -m json.tool $STEPPATH/config/ca.json)
39c39,49
<         ]
---
>         ],
>         "policy": {
>             "x509": {
>                 "allow": {
>                     "dns": [
>                         "*.lab.internal"
>                     ]
>                 },
>                 "allowWildcardNames": false
>             }
>         }
...
$ kill -HUP $(cat /tmp/lab-stepca/step-ca.pid); sleep 2; tail -n 4 /lab/logs/step-ca.log | cut -c1-200
time="2026-11-30T05:56:06-05:00" level=info certificate=MIICSzCCAfCgAwIBAgIRALxCep4TSuUVLSDNsakFfdswCgYIKoZIzj0EAwIwSjEbMBkGA1UEChMSQnl0ZXNOYXRpb24gTGFiIENBMSswKQYDVQQDEyJCeXRlc05hdGlvbiBMYWIgQ0EgSW50
2026/11/30 05:56:11 reloading ...
2026/11/30 05:56:11 Building new tls configuration using step-ca x509 Signer Interface
2026/11/30 05:56:11 Serving HTTPS on 127.0.0.1:9000 ...
...
$ step ca certificate www.example.com /tmp/lab-stepca/example2.crt /tmp/lab-stepca/example2.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
The request was forbidden by the certificate authority: dns name "www.example.com" not allowed
Re-run with STEPDEBUG=1 for more info.
...
$ step ca certificate printer.lab.internal /tmp/lab-stepca/printer.crt /tmp/lab-stepca/printer.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt && step certificate inspect /tmp/lab-stepca/printer.crt --short
...
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2052...6102]
  Subject:     printer.lab.internal
  Issuer:      BytesNation Lab CA Intermediate CA
  Provisioner: admin@lab.internal [ID: BODW...DcQQ]
  Valid from:  2026-11-30T10:55:13Z
          to:  2026-12-01T10:56:13Z
...
$ step ca certificate a.b.lab.internal /tmp/lab-stepca/ab.crt /tmp/lab-stepca/ab.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
The request was forbidden by the certificate authority: dns name "a.b.lab.internal" not allowed
Re-run with STEPDEBUG=1 for more info.
...
$ step ca certificate lab.internal /tmp/lab-stepca/bare.crt /tmp/lab-stepca/bare.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
The request was forbidden by the certificate authority: dns name "lab.internal" not allowed
Re-run with STEPDEBUG=1 for more info.
...

step-ca logged the refusal with status 403. My grep -o pattern stopped at the first escaped quote, so the error text is cut short in this line:

$ grep -E 'www.example.com' /lab/logs/step-ca.log | tail -1 | grep -oE 'error="[^"]*"|status=[0-9]+'
error="dns name \"
status=403
...

*.lab.internal matches exactly one label. printer.lab.internal passed. a.b.lab.internal and the bare lab.internal were refused. Two more limits apply:

  • The policy runs inside step-ca before it signs. A stolen intermediate key bypasses it. Only X.509 Name Constraints in the CA certificate itself make clients refuse out-of-scope names, per RFC 5280 section 4.2.1.10. Part 2 showed that step ca init did not add them. You need a custom template when you create the root or intermediate. I did not build that in this run.
  • A policy is not revocation. The www.example.com certificate issued before the policy went back in kept working after the reload, in the 05:58 ET rerun:
$ cp /tmp/lab-stepca/ca.json.with-policy $STEPPATH/config/ca.json && kill -HUP $(pgrep -x step-ca); sleep 2; tail -n 2 /lab/logs/step-ca.log | cut -c1-120
2026/11/30 05:58:37 Building new tls configuration using step-ca x509 Signer Interface
2026/11/30 05:58:37 Serving HTTPS on 127.0.0.1:9000 ...
...
$ step ca certificate www.example.com /tmp/lab-stepca/example2.crt /tmp/lab-stepca/example2.key --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
The request was forbidden by the certificate authority: dns name "www.example.com" not allowed
Re-run with STEPDEBUG=1 for more info.
...
$ curl -sS -o /dev/null -w '%{http_code} ssl_verify_result=%{ssl_verify_result}\n' --resolve www.example.com:8444:127.0.0.1 https://www.example.com:8444/
200 ssl_verify_result=0
...

I killed that server and deleted the files.

Removing the root again

Take the root back out of the system store:

$ step certificate uninstall --all /tmp/lab-stepca/step/certs/root_ca.crt
Certificate /tmp/lab-stepca/step/certs/root_ca.crt has been removed.
...
$ ls -l /usr/local/share/ca-certificates/; grep -c 'BEGIN CERT' /etc/ssl/certs/ca-certificates.crt; sha256sum /etc/ssl/certs/ca-certificates.crt
total 0
148
e9c7b63ee2623386e9b0a3ee32f499d01a8ea23dc83b8383ddff9f8e749543b7  /etc/ssl/certs/ca-certificates.crt
...
$ ls -l /etc/ssl/certs | grep -i bytesnation || echo 'no BytesNation links in /etc/ssl/certs'
lrwxrwxrwx 1 root root     70 Nov 30 05:56 5518d5ea.0 -> BytesNation_Lab_CA_Root_CA_110545153846565097045850672600281854417.pem
lrwxrwxrwx 1 root root    103 Nov 30 05:56 BytesNation_Lab_CA_Root_CA_110545153846565097045850672600281854417.pem -> /usr/local/share/ca-certificates/BytesNation_Lab_CA_Root_CA_110545153846565097045850672600281854417.crt
...

The bundle hash went back to the original, but uninstall left two dangling symlinks in /etc/ssl/certs. They point at a file that is gone, so they trust nothing. They are still clutter, and they are exactly what a later audit trips over. update-ca-certificates --fresh rebuilt the directory:

$ find /etc/ssl/certs -xtype l
/etc/ssl/certs/BytesNation_Lab_CA_Root_CA_110545153846565097045850672600281854417.pem
/etc/ssl/certs/5518d5ea.0
...
$ update-ca-certificates --fresh 2>&1 | tail -4
rehash: warning: skipping ca-certificates.crt, it does not contain exactly one certificate or CRL
148 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
...
$ find /etc/ssl/certs -xtype l | wc -l; ls -l /etc/ssl/certs | grep -ci bytesnation; sha256sum /etc/ssl/certs/ca-certificates.crt
0
0
e9c7b63ee2623386e9b0a3ee32f499d01a8ea23dc83b8383ddff9f8e749543b7  /etc/ssl/certs/ca-certificates.crt
...

And the client failed again, as it should:

$ curl -sS -o /dev/null https://app.lab.internal/
curl: (60) SSL certificate problem: unable to get local issuer certificate
...

Part 7: expired certificates and renewal that runs late

A certificate that expires while you watch

step-ca refused a one-minute certificate at first:

$ step ca certificate old.lab.internal /tmp/lab-stepca/old.crt /tmp/lab-stepca/old.key --not-after 1m --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
...
The request was forbidden by the certificate authority: requested duration of 2m0s is less than the authorized minimum certificate duration of 5m0s.
Re-run with STEPDEBUG=1 for more info.
...

The message says two minutes because of the one-minute backdate. The minimum is a claim, step-ca’s name for a per-CA or per-provisioner limit. I lowered it for the lab and set the ACME provisioner’s default to five minutes so Caddy would get short certificates too:

$ diff <(python3 -m json.tool /tmp/lab-stepca/ca.json.pre-claims) <(python3 -m json.tool $STEPPATH/config/ca.json)
37c37,41
<                 "name": "acme"
---
>                 "name": "acme",
>                 "claims": {
>                     "minTLSCertDuration": "1m",
>                     "defaultTLSCertDuration": "5m"
>                 }
48a53,55
>         },
>         "claims": {
>             "minTLSCertDuration": "1m"
...
$ kill -HUP $(cat /tmp/lab-stepca/step-ca.pid); sleep 2; tail -n 2 /lab/logs/step-ca.log | cut -c1-120
2026/11/30 05:56:16 Building new tls configuration using step-ca x509 Signer Interface
2026/11/30 05:56:16 Serving HTTPS on 127.0.0.1:9000 ...
...

The certificate for old.lab.internal ran from 10:55:18 to 10:57:18 UTC. I served it with s_server, chain included. My first check ran at 10:56:20 and passed. At 10:57:38 it failed:

$ step ca certificate old.lab.internal /tmp/lab-stepca/old.crt /tmp/lab-stepca/old.key --not-after 1m --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt && step certificate inspect /tmp/lab-stepca/old.crt --short && date -u
...
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2996...1308]
  Subject:     old.lab.internal
  Issuer:      BytesNation Lab CA Intermediate CA
  Provisioner: admin@lab.internal [ID: BODW...DcQQ]
  Valid from:  2026-11-30T10:55:18Z
          to:  2026-11-30T10:57:18Z
Mon Nov 30 10:56:18 UTC 2026
...
$ date -u; curl -sS -o /dev/null -w '%{http_code} verify=%{ssl_verify_result}\n' --cacert /tmp/lab-stepca/step/certs/root_ca.crt --resolve old.lab.internal:8445:127.0.0.1 https://old.lab.internal:8445/
Mon Nov 30 10:56:20 UTC 2026
200 verify=0
...
$ date -u; curl -sS -o /dev/null --cacert /tmp/lab-stepca/step/certs/root_ca.crt --resolve old.lab.internal:8445:127.0.0.1 https://old.lab.internal:8445/
Mon Nov 30 10:57:38 UTC 2026
curl: (60) SSL certificate problem: certificate has expired
...
$ echo | openssl s_client -connect 127.0.0.1:8445 -servername old.lab.internal -CAfile /tmp/lab-stepca/step/certs/root_ca.crt 2>&1 | grep -E 'verify error|Verify return code' | sort -u
Verify return code: 10 (certificate has expired)
verify error:num=10:certificate has expired
...
$ python3 -c "import ssl,socket; c=ssl.create_default_context(cafile='/tmp/lab-stepca/step/certs/root_ca.crt'); c.wrap_socket(socket.create_connection(('127.0.0.1',8445)), server_hostname='old.lab.internal')" 2>&1 | tail -1
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1029)
...

Then I tried to renew it. My first step ca renew had its flags after the file names. Put the flags first:

$ step ca renew --force /tmp/lab-stepca/old.crt /tmp/lab-stepca/old.key --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt
too many positional arguments were provided in 'step ca renew <crt-file> <key-file>'
...
$ step ca renew --force --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt /tmp/lab-stepca/old.crt /tmp/lab-stepca/old.key
The request lacked necessary authorization to be completed: certificate expired on 2026-11-30 10:57:18 +0000 UTC
Re-run with STEPDEBUG=1 for more info.
...
$ grep 'renew' /lab/logs/step-ca.log | tail -1 | grep -oE 'path=[^ ]+|status=[0-9]+|error="[^"]*"'
error="cahandler.Renew: authority.authorizeRenew: The request lacked necessary authorization to be completed: certificate expired on 2026-11-30 10:57:18 +0000 UTC"
path=/renew
status=401
...

Renewal in step-ca works by proving you hold a valid certificate. An expired one proves nothing, so you go back to a provisioner and get a new one. step-ca has an allowRenewalAfterExpiry claim, and the smallstep configuration docs mark it with a warning. I left it off. Re-issuing through the JWK provisioner and then renewing while the certificate was still valid both worked:

$ step ca certificate old.lab.internal /tmp/lab-stepca/old.crt /tmp/lab-stepca/old.key --force --not-after 10m --provisioner admin@lab.internal --provisioner-password-file /tmp/lab-stepca/ca-password --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt && step certificate inspect /tmp/lab-stepca/old.crt --short
...
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2614...1866]
  Subject:     old.lab.internal
  Issuer:      BytesNation Lab CA Intermediate CA
  Provisioner: admin@lab.internal [ID: BODW...DcQQ]
  Valid from:  2026-11-30T10:56:38Z
          to:  2026-11-30T11:07:38Z
...
$ step ca renew --force --ca-url https://ca.lab.internal:9000 --root /tmp/lab-stepca/step/certs/root_ca.crt /tmp/lab-stepca/old.crt /tmp/lab-stepca/old.key && step certificate inspect /tmp/lab-stepca/old.crt --short
Your certificate has been saved in /tmp/lab-stepca/old.crt.
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2144...1026]
  Subject:     old.lab.internal
  Issuer:      BytesNation Lab CA Intermediate CA
  Provisioner: admin@lab.internal [ID: BODW...DcQQ]
  Valid from:  2026-11-30T10:56:38Z
          to:  2026-11-30T11:07:38Z
...

Caddy served an expired certificate for five minutes

With the five-minute ACME default in place, I wiped Caddy’s certificates and restarted it:

$ pkill -x caddy; sleep 1; rm -rf /tmp/lab-stepca/caddy/certificates; pgrep -a caddy || echo "caddy stopped, certificates wiped (ACME account kept)"
...
$ nohup caddy run --config Caddyfile.v4-nas-added --adapter caddyfile > /lab/logs/caddy-v4-short.log 2>&1 &
...
$ date -u; grep -E 'certificate obtained|background certificate maintenance' /lab/logs/caddy-v4-short.log | cut -c1-250
Mon Nov 30 10:57:44 UTC 2026
{"level":"info","ts":1796036259.8699992,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xcda56c47180"}
{"level":"info","ts":1796036260.1630774,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"app.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory"}
{"level":"info","ts":1796036260.165023,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"nas.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory"}
...
$ echo | openssl s_client -connect 127.0.0.1:443 -servername app.lab.internal 2>/dev/null | openssl x509 -noout -serial -dates
serial=23928CCFD61470AD75F7A12789F34732
notBefore=Nov 30 10:56:39 2026 GMT
notAfter=Nov 30 11:02:39 2026 GMT
...

Valid from 10:56:39 to 11:02:39 UTC, six minutes counting the backdate. Every 30 seconds, a small loop printed the time in UTC, the serial and end date of the certificate Caddy served, and the HTTP status curl got. The watch with the default renew_interval, started at 5:57:44 AM ET:

...
11:01:45Z  serial=23928CCFD61470AD75F7A12789F34732 notAfter=Nov 30 11:02:39 2026 GMT  curl=200
11:02:15Z  serial=23928CCFD61470AD75F7A12789F34732 notAfter=Nov 30 11:02:39 2026 GMT  curl=200
11:02:45Z  serial=23928CCFD61470AD75F7A12789F34732 notAfter=Nov 30 11:02:39 2026 GMT  curl=curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.se/docs/sslcerts.html  curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the webpage mentioned above. 000
11:03:15Z  serial=23928CCFD61470AD75F7A12789F34732 notAfter=Nov 30 11:02:39 2026 GMT  curl=curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.se/docs/sslcerts.html  curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the webpage mentioned above. 000
...
11:07:15Z  serial=23928CCFD61470AD75F7A12789F34732 notAfter=Nov 30 11:02:39 2026 GMT  curl=curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.se/docs/sslcerts.html  curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the webpage mentioned above. 000
11:07:45Z  serial=53A6B6D926159F752544428A7BBB649B notAfter=Nov 30 11:12:39 2026 GMT  curl=200
11:08:15Z  serial=53A6B6D926159F752544428A7BBB649B notAfter=Nov 30 11:12:39 2026 GMT  curl=200

Caddy’s log at the moment it woke up:

$ grep -E 'tls.renew' /lab/logs/caddy-v4-short.log | cut -c1-260
{"level":"info","ts":1796036859.8814108,"logger":"tls.renew","msg":"acquiring lock","identifier":"app.lab.internal"}
...
{"level":"info","ts":1796036859.8821573,"logger":"tls.renew","msg":"lock acquired","identifier":"app.lab.internal"}
...
{"level":"info","ts":1796036859.8823347,"logger":"tls.renew","msg":"renewing certificate","identifier":"app.lab.internal","remaining":-299.882332288}
...
{"level":"info","ts":1796036860.1686718,"logger":"tls.renew","msg":"certificate renewed successfully","identifier":"app.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory"}
{"level":"info","ts":1796036860.1687918,"logger":"tls.renew","msg":"releasing lock","identifier":"app.lab.internal"}
...

remaining: -299.88 means the certificate had been expired for five minutes when Caddy renewed it. Caddy’s docs say its maintenance loop scans managed certificates every renew_interval, 10 minutes by default. A certificate that lives six minutes can expire between two scans. The maintenance loop started at ts 1796036259.87, which is 10:57:39 UTC, and the renewal ran at ts 1796036859.88, 11:07:39 UTC, exactly 600 seconds later.

The fix is to scan more often than the renewal window is long:

$ diff Caddyfile.v4-nas-added Caddyfile
5a6
> 	renew_interval 1m
...
$ caddy reload --config Caddyfile --adapter caddyfile --address 127.0.0.1:2019 2>&1 | grep -v '^{"level":"info"'; echo reloaded at $(date -u +%H:%M:%SZ)
...

I applied that with caddy reload at 11:10:45 UTC. It did not take. The next certificate, valid to 11:12:39, expired with no renewal attempt, and curl failed from 11:12:46 until the old 10-minute scan came round at 11:17:39. The watch after the reload with renew_interval 1m, started at 6:10:45 AM ET, and the count of maintenance loop starts in Caddy’s log for that whole process:

...
11:12:15Z  serial=53A6B6D926159F752544428A7BBB649B notAfter=Nov 30 11:12:39 2026 GMT  curl=200
11:12:46Z  serial=53A6B6D926159F752544428A7BBB649B notAfter=Nov 30 11:12:39 2026 GMT  curl=curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.se/docs/sslcerts.html  curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the webpage mentioned above. 000
...
11:16:46Z  serial=53A6B6D926159F752544428A7BBB649B notAfter=Nov 30 11:12:39 2026 GMT  curl=curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.se/docs/sslcerts.html  curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the webpage mentioned above. 000
11:17:16Z  serial=53A6B6D926159F752544428A7BBB649B notAfter=Nov 30 11:12:39 2026 GMT  curl=curl: (60) SSL certificate problem: certificate has expired More details here: https://curl.se/docs/sslcerts.html  curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the webpage mentioned above. 000
11:17:46Z  serial=424419CA6375271C347DB0B31FD43377 notAfter=Nov 30 11:22:39 2026 GMT  curl=200
$ grep -cE 'started background certificate maintenance' /lab/logs/caddy-v4-short.log; grep -E 'tls.renew|maintenance' /lab/logs/caddy-v4-short.log | cut -c1-220 | tail -6
1
...
{"level":"info","ts":1796037460.1630955,"logger":"tls.renew","msg":"certificate renewed successfully","identifier":"app.lab.internal","issuer":"ca.lab.internal:9000-acme-acme-directory"}
{"level":"info","ts":1796037460.1631632,"logger":"tls.renew","msg":"releasing lock","identifier":"app.lab.internal"}
...

Only one started background certificate maintenance line, from the first start. That fits Caddy keeping its certificate cache and its maintenance loop across a reload. I did not read the source to confirm it. What I can say is that in this run the new interval took effect only after a full stop and start. I saw the same thing on November 21 on a different machine.

After a restart with renew_interval 1m, Caddy never served an expired certificate again. It overcorrected instead. The watch in the block below started at 6:18:52 AM ET, after the full restart:

$ pkill -x caddy; sleep 1; rm -rf /tmp/lab-stepca/caddy/certificates; pgrep -a caddy || echo "caddy stopped, certificates wiped"
...
$ nohup caddy run --config Caddyfile --adapter caddyfile > /lab/logs/caddy-v5-renew1m.log 2>&1 &
...
$ cat /lab/logs/14d-renewal-watch-restart.log
...
11:18:52Z  serial=C514EE89C4D66A21A387930ADD0B3C12 notAfter=Nov 30 11:23:47 2026 GMT  curl=200
11:19:22Z  serial=C514EE89C4D66A21A387930ADD0B3C12 notAfter=Nov 30 11:23:47 2026 GMT  curl=200
11:19:52Z  serial=6BF51DA18A7DA8329CE1A55F7C870AD7 notAfter=Nov 30 11:24:47 2026 GMT  curl=200
11:20:22Z  serial=6BF51DA18A7DA8329CE1A55F7C870AD7 notAfter=Nov 30 11:24:47 2026 GMT  curl=200
11:20:52Z  serial=5BD9B896803E6228A5D8AFB63035860C notAfter=Nov 30 11:25:47 2026 GMT  curl=200
11:21:22Z  serial=5BD9B896803E6228A5D8AFB63035860C notAfter=Nov 30 11:25:47 2026 GMT  curl=200
11:21:52Z  serial=93C40550707E25E063CE017DB714EFA4 notAfter=Nov 30 11:26:47 2026 GMT  curl=200
11:22:22Z  serial=93C40550707E25E063CE017DB714EFA4 notAfter=Nov 30 11:26:47 2026 GMT  curl=200
11:22:52Z  serial=A109CDFECA109827C9789CE1C3F072A1 notAfter=Nov 30 11:27:47 2026 GMT  curl=200
11:23:22Z  serial=A109CDFECA109827C9789CE1C3F072A1 notAfter=Nov 30 11:27:47 2026 GMT  curl=200
...
$ grep -E 'renewing certificate' /lab/logs/caddy-v5-renew1m.log | grep app.lab | cut -c1-200
{"level":"info","ts":1796037587.47559,"logger":"tls.renew","msg":"renewing certificate","identifier":"app.lab.internal","remaining":240.524412503}
{"level":"info","ts":1796037647.4782932,"logger":"tls.renew","msg":"renewing certificate","identifier":"app.lab.internal","remaining":240.521709536}
{"level":"info","ts":1796037707.4802816,"logger":"tls.renew","msg":"renewing certificate","identifier":"app.lab.internal","remaining":240.519721737}
{"level":"info","ts":1796037767.480442,"logger":"tls.renew","msg":"renewing certificate","identifier":"app.lab.internal","remaining":240.51955968}
{"level":"info","ts":1796037827.4773579,"logger":"tls.renew","msg":"renewing certificate","identifier":"app.lab.internal","remaining":240.522645013}
...
$ grep -E 'emergency renewal window' /lab/logs/caddy-v5-renew1m.log | head -1 | cut -c1-600
{"level":"warn","ts":1796037587.472579,"logger":"tls","msg":"certificate is in emergency renewal window; expiration imminent","subjects":["app.lab.internal"],"expiration":1796037828,"ari_cert_id":"","next_ari_update":null,"renew_check_interval":60,"window_start":-6795364578.8713455,"window_end":-6795364578.8713455,"remaining":240.527422419}
...

The emergency line is cut at 600 characters by my cut, so it ends mid-field. A new certificate every minute, for each name. step-ca logged two finalized orders, one per name, at 06:18:47 ET for the first issue after the restart, then two more every minute after:

$ grep -c 'path=/acme/acme/order/.*/finalize' /lab/logs/step-ca.log; grep 'path=/acme/acme/order/.*/finalize' /lab/logs/step-ca.log | awk '{print $1}' | sort | uniq -c | tail -12
20
      1 time="2026-11-30T05:55:46-05:00"
      1 time="2026-11-30T05:56:00-05:00"
      2 time="2026-11-30T05:57:40-05:00"
      2 time="2026-11-30T06:07:40-05:00"
      2 time="2026-11-30T06:17:40-05:00"
      2 time="2026-11-30T06:18:47-05:00"
      2 time="2026-11-30T06:19:47-05:00"
      2 time="2026-11-30T06:20:47-05:00"
      2 time="2026-11-30T06:21:47-05:00"
      2 time="2026-11-30T06:22:47-05:00"
      2 time="2026-11-30T06:23:47-05:00"
...

The earlier pairs line up with the story above: 05:57:40 is the restart with five-minute certificates, 06:07:40 is the renewal five minutes late, and 06:17:40 is the second late renewal after the reload. A fresh five-minute certificate has about four minutes left at the next scan, and Caddy treated four minutes as an emergency every time. Nothing broke here. Against a public CA, one order per name per minute is the kind of traffic rate limits exist to stop. I stopped the test after five minutes. I did not try a lifetime between five minutes and 24 hours, so I cannot tell you where the storm stops.

I would not expect either problem with step-ca’s 24-hour default and Caddy’s 10-minute scan, though I did not run it that long. Both showed up as soon as I cut lifetimes to minutes and left the client’s schedule alone. Pick the lifetime and the client’s renewal schedule together, and restart the client, not just reload it, when you change the schedule.

Verification checklist

Run these against your own setup:

  • step ca health --ca-url https://ca.lab.internal:9000 --root root_ca.crt prints ok
  • Caddy’s log shows "issuer":"ca.lab.internal:9000-acme-acme-directory", not "issuer":"local"
  • openssl s_client -showcerts lists two certificates: the leaf, then your intermediate
  • curl -v shows subjectAltName: host "NAME" matched and SSL certificate verify ok without -k
  • step ca certificate for a name outside your domain is refused with not allowed
  • After you remove a root, find /etc/ssl/certs -xtype l prints nothing

Teardown and rollback

Inside the container:

bash
pkill -x caddy
kill STEP_CA_PID APP_PID S_SERVER_PIDS
rm -rf /tmp/lab-stepca /opt/lab-stepca /root/.config/caddy /root/.local/share/caddy
cp /tmp/hosts.pre-stepca-lab /etc/hosts
update-ca-certificates --fresh

Caddy run as root writes two things outside the storage path you give it:

$ ls -la /root/.config/caddy /root/.local/share/caddy 2>&1
/root/.config/caddy:
total 12
drwx------ 2 root root 4096 Nov 30 05:55 .
drwx------ 3 root root 4096 Nov 30 05:55 ..
-rw------- 1 root root  744 Nov 30 06:18 autosave.json

/root/.local/share/caddy:
total 12
drwx------ 2 root root 4096 Nov 30 05:55 .
drwx------ 3 root root 4096 Nov 30 05:55 ..
-rw------- 1 root root   36 Nov 30 05:55 instance.uuid
...

Both were created at 05:55 ET on the first start, so I removed both.

Two listeners survived the first pass, and it was the PID file problem from Part 5 again. The saved PIDs for the app and the 8445 s_server were wrong, so kill missed them:

$ pkill -x caddy; kill $(cat /tmp/lab-stepca/step-ca.pid) $(cat /tmp/lab-stepca/app.pid) $(cat /tmp/lab-stepca/s_server.pid) $(cat /tmp/lab-stepca/s_server3.pid); sleep 2; echo stopped
...
$ pgrep -a caddy || echo 'no caddy'; pgrep -a step-ca || echo 'no step-ca'; pgrep -af 'openssl s_server' | grep -v pgrep || echo 'no s_server'; pgrep -af 'http.server 8080' | grep -v pgrep || echo 'no app'
...
8006 openssl s_server -accept 127.0.0.1:8445 -cert old.crt -cert_chain old-chain.crt -key old.key -www -quiet
3664 python3 -m http.server 8080 --bind 127.0.0.1
...
$ ss -ltn '( sport = :80 or sport = :443 or sport = :9000 or sport = :8080 or sport = :2019 or sport = :8443 or sport = :8444 or sport = :8445 )'
State  Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0      4096       127.0.0.1:8445      0.0.0.0:*   
LISTEN 0      5          127.0.0.1:8080      0.0.0.0:*   
...

I killed them by the PIDs ps showed:

$ kill 8006 3664; sleep 1; ps -eo pid,args | grep -E '[s]_server|[h]ttp.server' || echo 'no s_server, no app'
  14453 bash -c kill 8006 3664; sleep 1; ps -eo pid,args | grep -E '[s]_server|[h]ttp.server' || echo 'no s_server, no app'
...
$ ss -ltn '( sport = :80 or sport = :443 or sport = :9000 or sport = :8080 or sport = :2019 or sport = :8443 or sport = :8444 or sport = :8445 )'
State Recv-Q Send-Q Local Address:Port Peer Address:Port
...

The only line left in the ps output is the shell that ran it. Check with ss -ltn after teardown, not with your PID files.

The rest of the rollback:

$ rm -rf /tmp/lab-stepca /opt/lab-stepca /root/.config/caddy /root/.local/share/caddy /lab/dl && echo removed
...
$ cp /tmp/hosts.pre-stepca-lab /etc/hosts && rm /tmp/hosts.pre-stepca-lab && grep -c lab.internal /etc/hosts; getent ahosts app.lab.internal | head -1 || echo 'app.lab.internal no longer resolves'
0
...
$ sha256sum /etc/ssl/certs/ca-certificates.crt; grep -c 'BEGIN CERT' /etc/ssl/certs/ca-certificates.crt; ls /usr/local/share/ca-certificates/ | wc -l; find /etc/ssl/certs -xtype l | wc -l; ls -l /etc/ssl/certs | grep -ci bytesnation
e9c7b63ee2623386e9b0a3ee32f499d01a8ea23dc83b8383ddff9f8e749543b7  /etc/ssl/certs/ca-certificates.crt
148
0
0
0
...
$ command -v step step-ca caddy || echo 'no step, step-ca or caddy on PATH'
...
$ getent ahosts app.lab.internal; echo "getent exit $?"
...

The bundle hash matches the one recorded before the lab. The four numbers after it are the certificate count, local certificates, dangling links and BytesNation links, all three of the last ones are 0. After /etc/hosts went back, app.lab.internal no longer resolved at all: getent printed no address and exited with status 2. On November 21, on a different machine, the same lookup went to an upstream resolver that answered for it. If your resolver answers for names it should not know, a typo in /etc/hosts can send traffic somewhere you did not expect.

Then I stopped the container, which Docker removes because it ran with --rm, and deleted the image I had pulled:

$ docker stop stepca-lab
stepca-lab
$ docker rmi debian@sha256:3cda3ca472ce45507a5109c6a3907093e24d9ae67d55954c9a07a45665dafba2
Untagged: debian:trixie
Deleted: sha256:<id>
Error response from daemon: No such image: debian:trixie
$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
$ docker images
IMAGE          ID             DISK USAGE   CONTENT SIZE   EXTRA
ubuntu:26.04   d66b366dac61        163MB         45.9MB        
$ docker volume ls
DRIVER    VOLUME NAME
$ docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
0f55cd95131e   bridge    bridge    local
d18a2fb88c25   host      host      local
42a14e2e81f4   none      null      local

The No such image line came from a second docker rmi debian:trixie I ran by tag in the same step. My log did not echo that command, and the tag was already gone with the first one. The only image left is ubuntu:26.04, which was there before I started, and the volume and network lists match the ones I took before the lab.

Common pitfalls

  • A Caddy log line that says certificate obtained successfully is not proof your CA signed it. Read the issuer field.
  • The ACME client needs the root too. Caddy’s ca_root is the setting for it. Other ACME clients have their own, check their docs.
  • http-01 means the CA connects to the name on port 80. If the CA’s DNS cannot resolve your service name, the order fails. A CA on the same box hides this. A CA in a separate VM will not.
  • Exit code 35 from curl against Caddy is a handshake abort, not a certificate problem. Exit code 60 is a verification failure. Read the number.
  • unable to get local issuer certificate means either the root is missing or the server did not send the intermediate. Check -showcerts first.
  • step certificate uninstall leaves dangling symlinks. Follow it with update-ca-certificates --fresh.
  • A PID file can point at the wrong process. Twice in this run a restart failed with Address already in use because the old listener was still up. Check ss -ltnp before you trust a restart.
  • Each extra store you add the root to, such as a browser’s own store or a Java keystore, is one more place to clean up. I did not test either here.
  • Short lifetimes need a client that checks often. Caddy’s default scan is every 10 minutes, and in this run a caddy reload did not change the scan interval. Restart Caddy after you change renew_interval.
  • Very short lifetimes make Caddy renew on every scan. Five-minute certificates with a one-minute scan meant one ACME order per name per minute.

What I did not run

  • X.509 Name Constraints on the root or intermediate. The policy test above is CA-side only.
  • A browser test, or any browser or Java trust store. Everything here is curl, OpenSSL, Python and the step CLI on the command line, and the container had no certutil or keytool.
  • The tls-alpn-01 and dns-01 challenges, ACME account binding, and certificate revocation.
  • Signature checks on the release downloads. I checked the sha256 and sha512 sums from the release checksum files only.
  • A long-running Caddy with the 24-hour default, or any lifetime between five minutes and 24 hours. Renewal was observed only with five-minute certificates.
  • A run on a normal host with systemd and sudo. This run was a root shell in a throwaway Docker container with docker-init as PID 1.
  • The first www.example.com test with the policy added afterwards, in that order, with a working chain. My restart of that listener failed, so I redid it with the policy taken out and put back, as described in Part 6.
step-caacmepkitlscertificatescaddytrust-storex509homelab

All field notes