Card 05/ 10

ExampleDifficulty: Intermediate2 min

Certificate Example: Reading a Website's Chain

Reading `openssl s_client` output for a real site, from the leaf certificate to the root.

openssl s_client connects to a server, runs the TLS handshake and prints the certificate chain it received, which makes the chain of trust visible. The output below is illustrative: it is trimmed to the chain, uses example names, and was not captured from a live site.

Terminaltext
openssl s_client -connect shop.example.com:443 -servername shop.example.com
depth=2 C = US, O = Example Root Trust, CN = Example Root CA R1
verify return:1
depth=1 C = US, O = Example Trust, CN = Example Issuing CA 2
verify return:1
depth=0 CN = shop.example.com
verify return:1
---
Certificate chain
 0 s:CN = shop.example.com
   i:C = US, O = Example Trust, CN = Example Issuing CA 2
   v:NotBefore: Sep  1 00:00:00 2026 GMT; NotAfter: Nov 30 23:59:59 2026 GMT
 1 s:C = US, O = Example Trust, CN = Example Issuing CA 2
   i:C = US, O = Example Root Trust, CN = Example Root CA R1
---
Verify return code: 0 (ok)
Illustrative `openssl s_client` output, trimmed to the chain and the verify result.

Three things are worth noticing.

Each issuer is the next subject. Under "Certificate chain", certificate 0 is the leaf: its subject (s:) is shop.example.com and its issuer (i:) is Example Issuing CA 2. Certificate 1 has that intermediate as its subject, issued by Example Root CA R1. Reading down, every i: line matches the s: line below it. That is the chain.

The root is not in the list. The server sent two certificates, the leaf and the intermediate. The root appears only in the depth=2 line at the top, because openssl found it in the local trust store. A list with only certificate 0, and a verify error, would mean the server is not sending its intermediate.

The result line is the verdict. Verify return code: 0 (ok) means every signature, date and link checked out. The -servername option sends SNI, so the server returns the certificate for this site; the validity line shows when it expires.