Skip to content
Visual explainer 3h 30m to learn 4 steps

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.

Topic 18 of 49

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.

SequenceTLS handshake (simplified)
Client
Server
  1. 1Hello, supported ciphers
    Client to Server: Hello, supported ciphers
  2. 2Hello, certificate chosen cipher
    Server to Client: Hello, certificate chosen cipher
  3. 3Verify cert, agree key material
    Client to Server: Verify cert, agree key material
  4. 4Finished, switch to encrypted
    Server to Client: Finished, switch to encrypted
  5. 5Encrypted application data
    Client to Server: Encrypted application data
LayersA certificate chain of trust
  1. 1
    Root CA

    Self-signed; pre-installed in the trust store; kept offline

  2. 2
    Intermediate CA

    Signed by the root; signs website certificates

  3. 3
    Leaf certificate

    Signed by the intermediate; SAN lists the host names

  4. 4
    Server 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).

FlowCertificate validation checks
  1. 1
    Build chain

    Leaf to intermediate to trusted root

  2. 2
    Check signatures

    Each cert signed by the next

  3. 3
    Check dates

    Now is between notBefore and notAfter

  4. 4
    Check name

    Host name matches a SAN entry

  5. 5
    Check 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.

SequenceTLS 1.3 full handshake
Client
Server
  1. 1ClientHello + key_share (X25519)
    Client to Server: ClientHello + key_share (X25519)
  2. 2ServerHello + key_share
    Server to Client: ServerHello + key_share
  3. 3Encrypted: Certificate
    Server to Client: Encrypted: Certificate
  4. 4Encrypted: CertificateVerify + Finished
    Server to Client: Encrypted: CertificateVerify + Finished
  5. 5Encrypted: Finished
    Client to Server: Encrypted: Finished
  6. 6Application data (HTTP)
    Client to Server: Application 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.

  1. 1
    Explain CAs and chains of trust~55m
  2. 2
    Inspect a certificate with openssl~55m
  3. 3
    Walk through a TLS 1.3 handshake~55m
  4. 4
    Explain 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.

bash
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 subjectAltName

Monitoring 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.

bash
#!/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
done

Quick 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.

Question 1

1A site works in your desktop browser but curl reports "unable to get local issuer certificate". What is the most likely cause?

Question 2

2In TLS 1.3, which message proves the server holds the private key for its certificate?

Question 3

3Does a certificate for *.example.com cover shop.eu.example.com?

Question 4

4Why is the industry shortening certificate lifetimes?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. 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.

  2. Exercise 2medium

    Find out which TLS versions a server accepts by testing TLS 1.1, 1.2 and 1.3 separately with openssl.

  3. 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.

Go deeper

ShareXLinkedInWhatsApp