PKI, certificates & TLS
Read a certificate chain and explain what a TLS handshake establishes.
By Invicly Tech, , in Cyber Security Fundamentals. About 10 minutes to read.
In short
Public key infrastructure binds identities to public keys through certificates signed by trusted certificate authorities. TLS uses these certificates to authenticate a server and establish an encrypted session, which is what the padlock in a browser represents.
Explained simply
When you visit your bank's website, how do you know it is really the bank and not a copy? A certificate answers this. It is a small file that says "this public key belongs to bank.example", signed by a trusted company called a certificate authority (CA).
Your browser and operating system come with a built-in list of trusted root CAs, called the trust store. Root CAs usually sign intermediate CAs, and intermediates sign website certificates. Following these signatures from the website up to a trusted root is called the chain of trust.
TLS (Transport Layer Security) is the protocol that uses these certificates. In a few quick messages, the browser checks the certificate, both sides agree on fresh encryption keys, and then all traffic is encrypted and protected from changes. HTTPS is simply HTTP sent inside TLS.
Certificates expire, and a CA can revoke (cancel) one early if its private key is stolen. Expired certificates are one of the most common causes of outages, so teams automate renewal and monitor expiry dates.
Press Play on a diagram to walk through it one step at a time.
- Client to Server: Hello, supported ciphers1Hello, supported ciphers
- Server to Client: Hello, certificate chosen cipher2Hello, certificate chosen cipher
- Client to Server: Verify cert, agree key material3Verify cert, agree key material
- Server to Client: Finished, switch to encrypted4Finished, switch to encrypted
- Client to Server: Encrypted application data5Encrypted application data
- 1Root CA
Self-signed; pre-installed in the trust store; kept offline
- 2Intermediate CA
Signed by the root; signs website certificates
- 3Leaf certificate
Signed by the intermediate; SAN lists the host names
- 4Server private key
Never shared; proves ownership in CertificateVerify
In depth
What is inside a certificate
Certificates use the X.509 format. The important fields are: Subject (who it is for), Issuer (which CA signed it), Validity (notBefore and notAfter dates), the Subject Public Key, and extensions. The Subject Alternative Name (SAN) extension lists the exact host names the certificate covers, such as example.com and www.example.com, or a wildcard like *.example.com, which covers one level only. Browsers check the name against the SAN, not the old Common Name field.
Other extensions matter too. Basic Constraints says whether the certificate is a CA (CA:TRUE) that may sign others. Key Usage and Extended Key Usage say what the key may be used for, such as server authentication or code signing. At the end comes the CA's signature over all these fields.
Public CAs must also log every certificate in public Certificate Transparency (CT) logs. You can search these logs, for example on crt.sh, to see every certificate issued for your domain.
- *.example.com covers a.example.com but not a.b.example.com
- Watch CT logs for certificates you did not request
- CA:TRUE on a leaf certificate is a serious red flag
How a client validates a certificate
A TLS client does several checks, and all must pass. First, it builds a chain: the server sends its leaf certificate plus intermediates, and the client links each certificate to the one that signed it until it reaches a root in its trust store. Second, it verifies every signature in that chain. Third, it checks that every certificate is inside its validity dates. Fourth, it checks that the host name it connected to matches the leaf's SAN. Fifth, it checks constraints and key usage, and where available, revocation status.
A very common server mistake is not sending the intermediate certificate. Some browsers fill the gap from cache, so the site looks fine for you but fails for curl, mobile apps or other servers. Always serve the full chain (leaf plus intermediates, never the root).
- 1Build chain
Leaf to intermediate to trusted root
- 2Check signatures
Each cert signed by the next
- 3Check dates
Now is between notBefore and notAfter
- 4Check name
Host name matches a SAN entry
- 5Check usage
Server auth allowed; revocation if known
The TLS 1.3 handshake in detail
TLS 1.3 (RFC 8446) needs only one round trip before data flows. The ClientHello lists supported cipher suites and includes a key share, the client's half of an ephemeral (EC)DHE exchange, usually X25519. The server answers with a ServerHello containing its own key share. Both can now compute the same secret, so everything after this point is encrypted.
The server then sends, encrypted, its certificate and a CertificateVerify message: a signature over the whole handshake so far, made with the certificate's private key. This proves the server holds that key and that nobody changed the messages. A Finished message closes each side's part.
TLS 1.3 removed old, weak options: no RSA key exchange, so forward secrecy is always on, and only AEAD ciphers such as TLS_AES_128_GCM_SHA256 and TLS_CHACHA20_POLY1305_SHA256. TLS 1.0 and 1.1 were formally deprecated in 2021 and should be disabled.
- Client to Server: ClientHello + key_share (X25519)1ClientHello + key_share (X25519)
- Server to Client: ServerHello + key_share2ServerHello + key_share
- Server to Client: Encrypted: Certificate3Encrypted: Certificate
- Server to Client: Encrypted: CertificateVerify + Finished4Encrypted: CertificateVerify + Finished
- Client to Server: Encrypted: Finished5Encrypted: Finished
- Client to Server: Application data (HTTP)6Application data (HTTP)
Revocation, expiry and shorter lifetimes
If a private key leaks, the CA revokes the certificate. Clients learn this in two ways. A CRL (certificate revocation list) is a signed list of revoked serial numbers. OCSP lets a client ask the CA about one certificate, and OCSP stapling lets the server attach a fresh signed answer to the handshake. In practice, revocation checking is patchy: many clients do not fail when they cannot reach the CA, and Let's Encrypt ended its OCSP service in 2025 in favour of CRLs.
Because revocation is weak, the industry is shortening certificate lifetimes instead. In 2025 the CA/Browser Forum voted to cut the maximum from 398 days to 200 days from March 2026, 100 days from March 2027 and 47 days from March 2029. Let's Encrypt certificates already last 90 days.
The lesson for defenders: automate renewal with ACME tools such as certbot, and monitor expiry so you get warned weeks before.
Learn it in 4 short steps
About 55m each. Track them with a timer in your plan.
- 1Explain CAs and chains of trust~55m
- 2Inspect a certificate with openssl~55m
- 3Walk through a TLS 1.3 handshake~55m
- 4Explain revocation and expiry problems~55m
Key points
- A certificate authority signs certificates that bind a key to a name.
- Clients trust a chain up to a root they already trust.
- TLS authenticates the server and encrypts the session.
- Expired or revoked certificates break the chain of trust.
Key terms
Tap a card to flip it. 0/4 known
Examples
Inspecting a live certificate chain with openssl
Step 1: connect with s_client. -servername sends SNI (the host name), which servers use to pick the right certificate. Step 2: read the chain section: depth 0 is the leaf, higher depths are intermediates. Step 3: pipe the leaf into openssl x509 to print subject, issuer, dates and SAN. Step 4: check Verify return code: 0 (ok) at the end of the s_client output; any other code explains what failed, such as an expired or unknown issuer.
openssl s_client -connect example.com:443 -servername example.com \
-showcerts </dev/null 2>/dev/null | grep -E 's:|i:|Verify return'
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null \
| openssl x509 -noout -subject -issuer -dates -ext subjectAltNameMonitoring certificate expiry
An expired certificate takes a site down for every user at once. Step 1: for each host name you own, fetch the certificate. Step 2: use openssl x509 -checkend, which exits non-zero if the certificate expires within the given number of seconds (30 days is 2592000). Step 3: run the script daily from cron or a CI job and send failures to chat or email. Step 4: also search crt.sh for your domain now and then, to spot certificates someone issued without your knowledge.
#!/bin/sh
for host in example.com www.example.com api.example.com; do
if ! openssl s_client -connect "$host:443" -servername "$host" </dev/null 2>/dev/null \
| openssl x509 -noout -checkend 2592000 >/dev/null; then
echo "WARNING: $host certificate expires within 30 days (or check failed)"
fi
doneQuick reference
- openssl s_client -connect host:443 -servername host shows the chain and Verify return code
- openssl x509 -noout -subject -issuer -dates -ext subjectAltName prints the key fields
- openssl x509 -checkend 2592000 fails if the cert expires within 30 days
- Serve leaf + intermediates; a missing intermediate breaks curl and mobile apps
- Browsers match the host name against SAN entries, not the Common Name
- TLS 1.3: 1 round trip, always forward secret, AEAD ciphers only
- Disable TLS 1.0 and 1.1; allow TLS 1.2 and 1.3
- Search crt.sh for your domain to see every publicly issued certificate
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Open any HTTPS site, click the padlock and view the certificate. Write down the issuer, the expiry date, the SAN names and how many certificates are in the chain.
- Exercise 2medium
Find out which TLS versions a server accepts by testing TLS 1.1, 1.2 and 1.3 separately with openssl.
- Exercise 3hard
Build a small lab PKI: create a root CA, issue a server certificate for lab.local with a SAN, and verify the chain with openssl verify.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Does the padlock mean a website is safe?
- No. It means the connection is encrypted and the certificate matches the name in the address bar. A phishing site can have a valid certificate for its own look-alike domain.
- What is the difference between SSL and TLS?
- SSL is the old name for the protocol, and all SSL versions are broken and disabled. TLS replaced it; people still say "SSL certificate" out of habit.
- Why does my company's network show its own CA on every website?
- Some companies inspect HTTPS traffic with a proxy that re-signs certificates using a company CA installed on managed devices. It lets them scan traffic, but it also means the proxy can see your data.
- How long are certificates valid now?
- Public TLS certificates are limited to 200 days from March 2026, dropping to 100 days in 2027 and 47 days in 2029. Many, like Let's Encrypt's, already last 90 days and renew automatically.