/glossary/openssl/certificate-chain
What is a certificate chain (chain of trust)?
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · OpenSSL 3.5.7 9 Jun 2026 (Library: OpenSSL 3.5.7 9 Jun 2026)updated 2026-10-20
- tool
- OpenSSL
- versions
- any
- os
- any
A certificate chain is the sequence of certificates that connects a server's own (leaf) certificate to a root certificate authority the client already trusts. Each certificate is signed by the next one up: leaf ← intermediate CA ← root CA. The server sends the leaf and the intermediates; the root comes from the client's trust store.
A three-level chain, verified
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout root.key -out root.pem -subj "/CN=Example Root" -days 30 2>/dev/null
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout int.key -out int.csr -subj "/CN=Example Intermediate" 2>/dev/null
printf 'basicConstraints=critical,CA:TRUE\nkeyUsage=critical,keyCertSign,cRLSign\n' > ca.ext
openssl x509 -req -in int.csr -CA root.pem -CAkey root.key -extfile ca.ext -out int.pem -days 20 2>/dev/null
openssl req -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -keyout leaf.key -out leaf.csr -subj "/CN=www.example.test" 2>/dev/null
openssl x509 -req -in leaf.csr -CA int.pem -CAkey int.key -out leaf.pem -days 10 2>/dev/null
openssl verify -CAfile root.pem leaf.pem 2>&1 | tail -1
openssl verify -CAfile root.pem -untrusted int.pem leaf.pemOutput
error leaf.pem: verification failed leaf.pem: OK
Without the intermediate, verification fails; with it (-untrusted passes certificates that may be used to build the chain but are not trusted themselves), the leaf verifies against the root.
Why it matters
- Servers must send the intermediates. Browsers sometimes fetch a missing one, but curl, Python and most APIs do not, and fail with
unable to get local issuer certificate. - Only the root needs to be trusted locally; intermediates can be replaced without touching every client.
openssl s_client -showcertsshows the chain a server actually sends.
Sources
Related pages
errors · opensslunable to get local issuer certificate (OpenSSL verify error 20)OpenSSL error 20, unable to get local issuer certificate, means the issuing CA is missing from the trust store or the chain. Add the CA or intermediate.codes · opensslOpenSSL verify error codes: 2, 10, 18, 19, 20, 21, 62OpenSSL X509 verify errors explained: 10 certificate has expired, 18 self-signed, 19 self-signed in chain, 20 unable to get local issuer, 62 hostname mismatch.flags · opensslopenssl s_client -servername: test TLS with SNIopenssl s_client -connect host:443 -servername host sends SNI so the server returns the right certificate. Add -brief for a summary or -showcerts for the chain.