PKI for FortiGate, Part 4: What the FortiGate Checks When a Peer Presents a Certificate
Part 3 ended with a certificate on the spoke and a tunnel that came up. This post reads what the hub does when the spoke presents that certificate. I captured a successful authentication with the IKE and fnbamd debugs on, so the lines below are real output from FortiOS 7.6.8, trimmed to the ones that carry meaning.
Knowing what a good run looks like is what makes the failures in Parts 5 and 6 readable.
The configuration being checked
Three objects on the hub decide what is accepted. This is the same configuration as in the step-ca post:
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"
next
end
CA_Cert_2 is the intermediate CA, as imported on the hub. The peer rule says: accept a certificate issued by that CA whose common name is spoke1.lab.
One more requirement, learned the hard way: a tunnel interface that no firewall policy references never starts IKE. The debug says ignoring request to establish IPsec SA, no policy configured, and a sniffer sees nothing on UDP 500 or 4500. My lab keeps a permanent ping-only policy for the overlay for this reason.
How to capture it
diagnose debug reset
diagnose debug application fnbamd -1
diagnose debug application ike -1
diagnose debug enable
diagnose vpn ike gateway clear name H1-S1-ISP1
Wait fifteen seconds, then:
diagnose debug disable
diagnose debug reset
If the debug output is scrolling while you type, the disable can fail with a parse error. Retype it. This capture is large: about 4,800 lines in thirty seconds, because a failing peer retries roughly once a second. Filter it before you share it. IKE debug includes the session keys for the exchange, so a raw capture belongs in a private file and not in a forum post or a support case.
Layer 1: the IKE identity
The spoke’s AUTH message arrives, carrying its certificate. IKE reads the identity from it:
ike V=root:0:H1-S1-ISP1:1: received peer identifier DER_ASN1_DN 'CN = spoke1.lab'
ike V=root:0:H1-S1-ISP1:1: Validating X.509 certificate
ike V=root:0:H1-S1-ISP1:1: peer cert, subject='spoke1.lab', issuer='Fortinet HomeLab Intermediate CA'
ike V=root:0:H1-S1-ISP1:1: peer CA cert, subject='Fortinet HomeLab Intermediate CA', issuer='Fortinet HomeLab Root CA'
ike V=root:0:H1-S1-ISP1:1: peer CA cert, subject='Fortinet HomeLab Root CA', issuer='Fortinet HomeLab Root CA'
ike V=root:0:H1-S1-ISP1:1: peer ID verified
The spoke presented three certificates: its own, the intermediate and the root. Each peer CA cert line names the certificate and its issuer, and the last has the same subject and issuer, because the root signs itself. peer ID verified means the identity in the certificate matches what the exchange claims. Nothing has been trusted yet. IKE now hands the certificate to the authentication daemon, fnbamd.
ike V=root:0:H1-S1-ISP1:1: building fnbam peer candidate list
ike V=root:0:H1-S1-ISP1:1: FNBAM_GROUP_NAME candidate 'PEER-SPOKE1'
ike V=root:0:H1-S1-ISP1:1: certificate validation pending
PEER-SPOKE1 is the user peer object from the configuration. It is the only candidate.
Layer 2: the chain and the revocation lists
fnbamd takes over. The lines I care about:
[554] fnbamd_cert_verify-Following cert chain depth 0
[305] fnbamd_add_crl_hash-new crl 'ROOT-CRL', issuer 'CN = Fortinet HomeLab Root CA', vfid 0
[305] fnbamd_add_crl_hash-new crl 'THEMIS-CRL', issuer 'CN = Fortinet HomeLab Intermediate CA', vfid 0
[408] __check_crl-CRL found: THEMIS-CRL
[425] __check_crl-***CERTIFICATE IS GOOD***
[628] fnbamd_cert_verify-Issuer found: CA_Cert_2 (SSL_DPI opt 1)
[554] fnbamd_cert_verify-Following cert chain depth 1
[408] __check_crl-CRL found: ROOT-CRL
[425] __check_crl-***CERTIFICATE IS GOOD***
[628] fnbamd_cert_verify-Issuer found: CA_Cert_1 (SSL_DPI opt 1)
[554] fnbamd_cert_verify-Following cert chain depth 2
Read this as a walk up the chain. Depth 0 is the leaf, depth 1 the intermediate, depth 2 the root.
- At depth 0 (
spoke1.lab),fnbamdfinds the CRL published by that certificate’s issuer,THEMIS-CRL, looks up the serial and reportsGOOD. It then finds the issuer in its CA store:CA_Cert_2. - At depth 1 (the intermediate), it finds the CRL published by its issuer, the root, which is
ROOT-CRL, and checks the intermediate’s serial against it. Then it findsCA_Cert_1. - At depth 2 (the root), there is no revocation check. The root is self-signed. Nothing above it can vouch for it or revoke it.
Two points follow. Each certificate is checked against the CRL of its own issuer. And the number of CRLs the hub needs is the number of CA tiers above the leaf, excluding the root. In this chain that is two: one from the intermediate for the leaves, one from the root for the intermediate. The ROOT-CRL line only appears because I loaded a root CRL onto the hub. Part 5 shows what happens when it is missing.
Layer 3: the peer rule
The chain is valid. Now the configuration decides whether this particular certificate is acceptable:
[734] fnbamd_cert_check_group_list-checking group with name 'PEER-SPOKE1'
[422] peer_subject_cn_check-Cert subject 'CN = spoke1.lab'
[351] __RDN_match-Checking 'CN' val 'spoke1.lab' -- match.
[460] peer_subject_cn_check-CN is good.
The common name matches the cn in PEER-SPOKE1. There is no separate log line for the ca setting in this capture. I did not test a certificate with a different common name, but this is the check that is meant to reject one. It is what separates “any certificate this CA ever issued” from “the certificate I expect from this device”.
The verdict
ike V=root:0:H1-S1-ISP1:2: certificate validation succeeded
ike V=root:0:H1-S1-ISP1:2: signature verification succeeded
ike V=root:0:H1-S1-ISP1:2: authentication succeeded
Two separate things are being confirmed. certificate validation is everything above: chain, revocation, name. signature verification is the proof that the spoke holds the private key: the AUTH payload was signed with it, and the signature verifies against the public key in the certificate. A copied certificate without its key would pass the first and fail the second.
After this the tunnel comes up and the child SA negotiates:
get vpn ipsec tunnel summary
'H1-S1-ISP1' 10.100.0.2:0 selectors(total,up): 1/1
What to take from it
- Authentication has three layers: the IKE identity, the chain with its revocation checks, and the peer rule. Each can fail separately.
- Revocation checking is one lookup per CA tier, each against that tier’s own CRL.
- The root is never revocation-checked. Its protection is that its key stays offline.
- The peer rule is what makes a CA shared with other systems safe to use for IPsec.
Part 5 breaks the chain and revocation layers on purpose.