step-ca for FortiGate IPsec Certificate Authentication: Issuing, Revoking and Testing
A pre-shared key is one secret shared by two devices. Revoke the device and you have to change the key, on both ends. Certificates fix that: each device has its own identity, and you can withdraw one without touching the others. To get that in my FortiGate lab I needed a certificate authority, and this post covers the one I built, how I issued certificates from it, how I tested revocation, and where it bit me.
Scope: a FortiGate hub and one spoke, IKEv2 with certificate authentication, FortiOS 7.6.8, step-ca 0.30.2 with step-cli 0.31.0. ADVPN shortcut tunnels aren’t covered here.
Why step-ca
I wanted something open source, small enough to run on a single Debian VM, scriptable from the command line, and able to publish a CRL that a FortiGate can fetch over HTTP. That’s a short list, and a few options meet it.
| Option | What it’s good at | Why I didn’t pick it for this |
|---|---|---|
| OpenSSL by hand | Nothing to install | No issuance tracking, and generating and publishing a CRL becomes your job |
| EJBCA Community | Full-featured CA, with SCEP, EST and OCSP | A much bigger system (Java, a database, a web admin) for a two-device lab |
| OpenBao / Vault PKI engine | Excellent if you already run it | I plan to run OpenBao for secrets later, but I wanted the CA standing alone |
| Microsoft AD CS | Native SCEP and a familiar tool in enterprises | Not open source, and it needs a Windows estate I don’t have |
| step-ca | One small Go binary, a good CLI, a CRL endpoint, short-lived and automatable certificates | Limits covered below |
step-ca fit the lab: step ca token and step ca sign are about as small as an issuance workflow gets, and the CRL is built in.
The CA layout
Two tiers, EC P-256 throughout (the FortiGate’s IKE proposal uses DH group 19, which is P-256, so the chain matches):
- Root CA (“Fortinet HomeLab Root CA”), valid ten years. Created on my admin workstation, passphrase-encrypted, and never on the CA server. It only ever signs the intermediate.
- Intermediate CA (“Fortinet HomeLab Intermediate CA”), valid five years. Its key is generated on the CA server,
themis, and the root signs the request. This is the CA that actually issues. - Provisioner: a JWK provisioner (
lab-admin) with certificate lifetimes from 5 minutes to 8760 hours (one year), defaulting to one year. - CRL: enabled, regenerated on every revocation (
generateOnRevoke), published over plain HTTP on port 9001, with HTTPS on 443 for the CA API.
Building the root and the intermediate
On the workstation that will hold the root. step prompts for a passphrase to encrypt the key:
step certificate create "Fortinet HomeLab Root CA" root_ca.crt root_ca.key \
--profile root-ca --kty EC --curve P-256 --not-after 87600h
On the CA server, generate the intermediate’s key and a CSR. The key never leaves the server:
sudo -u step step certificate create "Fortinet HomeLab Intermediate CA" \
/etc/step-ca/certs/intermediate_ca.csr \
/etc/step-ca/secrets/intermediate_ca.key \
--csr --kty EC --curve P-256 \
--password-file /etc/step-ca/secrets/intermediate_pass
Copy the CSR to the root workstation and sign it:
step certificate sign intermediate_ca.csr root_ca.crt root_ca.key \
--profile intermediate-ca --not-after 43800h > intermediate_ca.crt
Copy intermediate_ca.crt and the public root_ca.crt back to /etc/step-ca/certs/ on the server. The root key stays on the workstation. I ran this sequence in a scratch directory to check it: the chain verifies, and 87600h and 43800h give the ten-year and five-year lifetimes of the real CA.
Configuring step-ca
The whole config is one file, /etc/step-ca/config/ca.json:
{
"root": "/etc/step-ca/certs/root_ca.crt",
"crt": "/etc/step-ca/certs/intermediate_ca.crt",
"key": "/etc/step-ca/secrets/intermediate_ca.key",
"address": ":443",
"insecureAddress": "10.10.0.21:9001",
"dnsNames": ["themis.lab", "10.10.0.21"],
"logger": {"format": "text"},
"db": {"type": "badgerv2", "dataSource": "/etc/step-ca/db"},
"authority": {
"provisioners": [
{
"type": "JWK",
"name": "lab-admin",
"key": { "...": "public key" },
"claims": {
"minTLSCertDuration": "5m",
"maxTLSCertDuration": "8760h",
"defaultTLSCertDuration": "8760h"
}
}
]
},
"crl": {
"enabled": true,
"idpURL": "http://10.10.0.21:9001/1.0/crl",
"generateOnRevoke": true
},
"tls": {"minVersion": 1.2, "maxVersion": 1.3, "renegotiation": false}
}
insecureAddress is step-ca’s name for its plain-HTTP listener, which is where the CRL is served. Set generateOnRevoke explicitly: without it the CRL is only rebuilt on its cache interval (24 hours by default), not when you revoke something.
Running it
step-ca runs as an unprivileged step user under systemd, with the unit locked down:
[Unit]
Description=step-ca (Fortinet HomeLab CA)
After=network-online.target time-sync.target
Wants=network-online.target time-sync.target
[Service]
User=step
Group=step
Environment=STEPPATH=/etc/step-ca
ExecStart=/usr/bin/step-ca /etc/step-ca/config/ca.json --password-file=/etc/step-ca/secrets/intermediate_pass
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=/etc/step-ca/db
PrivateTmp=yes
ProtectKernelTunables=yes
ProtectControlGroups=yes
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
The host firewall only lets in what the CA needs: SSH from the hypervisor and the jumpbox, HTTPS on 443 and the CRL on 9001 from the management network.
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 10.10.0.3 to any port 22 proto tcp comment "SSH pve"
sudo ufw allow from 10.10.0.6 to any port 22 proto tcp comment "SSH jumpbox"
sudo ufw allow from 10.10.0.0/24 to any port 443 proto tcp comment "step-ca HTTPS"
sudo ufw allow from 10.10.0.0/24 to any port 9001 proto tcp comment "CRL HTTP"
sudo ufw enable
A CA that issues certificates with a wrong clock is a bad day, so the VM also syncs time from my authenticated NTP server (chrony with a keyed source).
Two design choices are worth explaining.
The CRL is served over HTTP, deliberately. A CRL is signed by the CA, so plain HTTP doesn’t weaken it: a modified list fails signature verification. It also means a FortiGate doesn’t need to trust anything to fetch it.
The CRL URL uses an IP address, not a name. FortiOS drops lookups for my .lab names unless there’s an entry for them in its own DNS database. I’d rather revocation never depended on DNS, so the URL is http://10.10.0.21:9001/1.0/crl.
Issuing a certificate to a FortiGate
The private key should never leave the FortiGate, so the device generates its own key and a CSR, and the CA signs the request.
1. Generate the key and CSR on the FortiGate (EC P-256, subject spoke1.lab):
execute vpn certificate local generate ec SPOKE1-IPSEC-3 secp256r1 spoke1.lab
The CSR is stored in the device config. You can copy it straight out of the CLI:
show full-configuration vpn certificate local SPOKE1-IPSEC-3
Take the PEM block from set csr and save it on the CA server as SPOKE1-IPSEC-3.csr.
2. Sign it on the CA server:
CA=https://10.10.0.21
ROOT=/etc/step-ca/certs/root_ca.crt
T=$(sudo step ca token spoke1.lab --san spoke1.lab \
--ca-url $CA --root $ROOT \
--issuer lab-admin --kid "$KID" \
--key /etc/step-ca/secrets/lab-admin.key.json \
--password-file /etc/step-ca/secrets/jwk_pass)
sudo step ca sign --ca-url $CA --root $ROOT --token "$T" \
SPOKE1-IPSEC-3.csr SPOKE1-IPSEC-3.crt
step certificate inspect SPOKE1-IPSEC-3.crt --short
X.509v3 TLS Certificate (ECDSA P-256) [Serial: 2000...3471]
Subject: spoke1.lab
Issuer: Fortinet HomeLab Intermediate CA
Provisioner: lab-admin [ID: Ocg5...r2qg]
Valid from: 2026-10-29T08:53:10Z
to: 2027-10-29T08:54:10Z
3. Import the leaf onto the FortiGate. step ca sign writes the leaf followed by the intermediate. FortiOS only wants the leaf (the CA certificates are imported separately), so paste just the first certificate block into the existing certificate object:
config vpn certificate local
edit "SPOKE1-IPSEC-3"
set certificate "-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----"
next
end
Then check it took:
get vpn certificate local details SPOKE1-IPSEC-3
The set csr line disappears from the object when the match succeeds, which is a quick way to tell the import worked.
The FortiGate side
Three objects tell the FortiGate what to trust and where to check revocation:
config vpn certificate crl
edit "THEMIS-CRL"
set http-url "http://10.10.0.21:9001/1.0/crl"
set update-interval 3600
next
end
config user peer
edit "PEER-SPOKE1"
set ca "CA_Cert_2"
set cn "spoke1.lab"
set cn-type string
next
end
config vpn ipsec phase1-interface
edit "H1-S1-ISP1"
set ike-version 2
set authmethod signature
set certificate "HUB1-IPSEC"
set peertype peer
set peer "PEER-SPOKE1"
set proposal aes256gcm-prfsha384
set dhgrp 19
next
end
CA_Cert_2 is the intermediate. The peer object pins which certificate the remote end has to present (issuer plus common name), rather than accepting any certificate the CA ever issued. update-interval 0 would only refresh the CRL when it expires, which is about 24 hours here, so an explicit interval is what bounds how long a revoked certificate stays trusted.
Testing revocation
I revoked a certificate and watched what the hub did. step-ca gives you two ways to revoke.
With the certificate’s own key. If you hold the certificate and its key, no token is needed:
step ca revoke --cert rt.crt --key rt.key --ca-url $CA --root $ROOT
With a token, when you don’t have the key (a device that’s been lost or compromised, which is the case that matters). step ca revoke wants the serial as a decimal number, while the certificate shows it in hex, so convert it first:
SERIAL=$(python3 -c "print(int('823C9ED069DFB7937275D870900CEF13', 16))")
T=$(sudo step ca token --revoke --ca-url $CA --root $ROOT \
--issuer lab-admin --kid "$KID" \
--key /etc/step-ca/secrets/lab-admin.key.json \
--password-file /etc/step-ca/secrets/jwk_pass \
$SERIAL)
sudo step ca revoke --ca-url $CA --root $ROOT --token "$T" $SERIAL
step crl inspect --insecure http://10.10.0.21:9001/1.0/crl | grep -E "Serial Number|Revocation Date"
The CRL listing prints each serial in decimal with the hex in brackets, so it’s easy to check you revoked the right one. It lists the serial immediately, because generateOnRevoke rebuilds the CRL on the spot. For this run I’d lowered the hub’s update-interval to 300 seconds and never ran a manual import.
| Time | Event |
|---|---|
| 08:13:29 | Certificate revoked on the CA; CRL regenerated |
| 08:15:33 | I cleared the IKE gateway on the hub. The revoked certificate re-authenticated: “certificate validation succeeded”, tunnel up 1/1. The hub still held the old CRL |
| 08:22:16 | Cleared again. This time: __check_crl-CRL found: THEMIS-CRL, then ***CERTIFICATE IS REVOKED***, “certificate validation failed”, “authentication failed”, tunnel down 1/0 |
Both results matter.
Revocation worked, with no manual import. At a 300-second interval the hub fetched the new CRL by itself some time between those two tests. FortiOS doesn’t show the last-fetch time anywhere I could find, so the proof is behavioural.
It didn’t work immediately. For two minutes after revocation the revoked certificate was still accepted. The exposure window is the CRL refresh interval plus the time until the next IKE authentication: an established tunnel isn’t re-checked, so it can survive for the IKE SA lifetime (86400 seconds in my config) unless you clear the gateway. If you revoke a certificate because a device is compromised, clear its gateway as part of the procedure:
diagnose vpn ike gateway clear name H1-S1-ISP1
A revoked peer also doesn’t go quiet. Both ends keep retrying about once a second, which is why my debug capture of 30 seconds ran to about 4,800 lines. Filter it (__check_crl, REVOKED, validation, authentication). Before you paste a capture into a forum or attach it to a support case, remove the key lines: IKE debug prints the IKE and ESP session keys, and anyone with the capture and a packet trace of the session could decrypt it.
When the CRL is missing
I also tested what the hub does if it has no CRL at all. I deleted the CRL object and presented the revoked certificate again. The setting that controls this lives here:
config vpn certificate setting
config crl-verification
set expiry ignore
set leaf-crl-absence ignore
set chain-crl-absence ignore
end
end
leaf-crl-absence | What happened |
|---|---|
ignore (default) | No CRL check at all. The revoked certificate authenticated and the tunnel came up 1/1 |
revoke | fnbamd logged CRL of leaf cert is absent., then “certificate validation failed”. Tunnel down |
So the default is fail-open: if the hub can’t get the CRL, revocation silently stops working, and a certificate you revoked is trusted again. The revoke setting is fail-closed. If you pick it, a CRL fetch outage will drop tunnels at the next IKE authentication, so the CRL host becomes something you have to monitor.
Note what the failure looks like in the log. It says “certificate validation failed” and the only clue is the fnbamd line saying the CRL is absent. Nothing says “revoked”. If you go fail-closed, that’s the line to search for.
Also note expiry ignore, the third setting: it means an expired CRL is ignored too, which is a second route to the same silent failure. I haven’t tested that yet.
My production choice would be leaf-crl-absence revoke: a visible outage is better than invisible loss of revocation. That needs a CRL host you monitor, and you’d want the refresh interval well inside the CRL’s validity. chain-crl-absence revoke needs a CRL for the root as well, which I haven’t built.
Gotchas
Things that cost me time, in the order I hit them:
- Flags come before the positional arguments.
step ca tokenandstep ca revokestop parsing flags at the first positional argument. Put the serial or subject last, or you get “too many positional arguments”. step ca token --provisionerfailed with “The requested resource could not be found”. I’d replaced the provisioner entry inca.jsonwith ajqedit to set the lifetime claims, and that entry has noencryptedKey. The workaround is to pass--issuer,--kid,--keyand--password-file. The clean fix is to add provisioners withstep ca provisioner add, so the encrypted key is stored with it.sudohas no CA defaults. Undersudo,stepruns as root, which has no~/.step/config/defaults.json, sostep ca tokencomplains that--ca-urlis required. The key and password files are only readable by thestepuser, sosudois needed. Pass--ca-urland--rootexplicitly every time.step ca revokehas no--provisioner. It takes the token you generated with--revoke, or the certificate and its key.step ca signreturns a bundle (leaf plus intermediate). FortiOS imports only the leaf, so give it the first block.- A tunnel needs a firewall policy that references it. Without one, IKE never starts. The log says “ignoring request to establish IPsec SA, no policy configured” and a sniffer sees nothing on UDP 500 or 4500.
- Plain
showhides the CRL.show vpn certificate crllists the object but not theset crlblock. Useshow full-configuration vpn certificate crl, and| grep -c BEGINto count it. FortiOSgrephas no-E. execute vpn certificate crl import auto <name>prints nothing, success or not. Check with the command above.
Would I choose step-ca in a large production environment?
For a lab, yes without hesitation. For a large estate it depends what you’re issuing certificates for.
What it does well. It’s automation-first: short-lived certificates, a clean CLI and API, and several ways to authenticate requests. It’s small to run and easy to understand, which matters when the thing you’re protecting is the root of your trust.
What I’d change.
- Keys. My intermediate key and its password file sit on disk. In production the intermediate key belongs in an HSM or a managed KMS, and the root should be offline with a documented key ceremony and more than one copy.
- Enrolment protocols. In the version I ran, step-ca has no EST, SCEP needs an RSA intermediate, and OCSP isn’t in the open-source build. FortiOS can enrol with SCEP (FortiManager uses it for certificate templates) and has an EST client, so a large FortiGate fleet would push me towards a CA that speaks those natively, or towards an RSA intermediate for SCEP.
- Availability and monitoring. A CA that’s down can’t issue, and with
leaf-crl-absence revokea CRL host that’s down can drop tunnels. That needs redundancy and alerting on CRL freshness. - Process. Who can request a certificate, who approves a revoke, and how fast a compromised device’s gateway gets cleared are all decisions that matter more than the CA software.
So: step-ca for the lab and for small, automation-heavy deployments. For a large FortiGate estate I’d look at EJBCA or an enterprise CA for the enrolment protocols and HSM integration, and compare it with step-ca fed by an RSA intermediate for SCEP.
Recap
- Per-device certificates let you revoke one device without touching the others, which a shared PSK can’t do.
- A small, offline root plus an online intermediate gives you a clean chain, and the FortiGate only needs the CA certificates, the CRL URL and a peer object.
- Revocation works, but it takes effect at the next CRL refresh plus the next IKE authentication. Clear the gateway when it matters.
- The default
crl-verificationsettings are fail-open. Decide on purpose.