7 min read
Leaf, Intermediate, and Root Certificate. TLS Details Simply Explained
A simple explanation of leaf, intermediate, and root certificates in TLS, their roles, and how they work together to establish secure connections.
During the weekend, I read about eMudhra's mistake on issuing simple numbers for its private key. That got me researching more about TLS, and I found out that the process is actually quite interesting and not as simple as I thought. In this blog, we will explore TLS in detail without any technical prerequisites. We will go from the top level to the rock bottom concept.
What is TLS?
TLS is a protocol that ensures the data you sent can't be read nor modified by someone that intercepts it. If you see a website with a padlock icon or HTTPS in the url, it means that the website uses TLS.
To put it simply, TLS encrypts the data being sent between the client and the server. A human wouldn't be able to read the data, as it will just look like random characters.
I'm going to demonstrate this concept with an example where I intercept the data being sent between client and server.
Intercepting the data like this is called a man-in-the-middle (MITM) attack
Request Without TLS
Imagine a login form on a website that only uses plain HTTP. When you press "Login", your browser sends something like this:
POST /login HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
username=khalisa&password=supersecret123
If I sit somewhere between you and the server (the same café Wi-Fi, a compromised router, etc.) and capture the traffic
with a tool like Wireshark or tcpdump, I see exactly that. Every character. Your username, your password, all in plain text.
Worse, I can also change it. I could swap the page the server sends back with my own fake page, and your browser would happily show it.
Request With TLS
Now the same request, but over HTTPS. What I capture in the middle looks more like this:
17 03 03 00 4a 8f 2c 91 e7 3b a0 5d 1f c4 77 09
e2 6b 3d 98 a1 0c 5f 7e 44 b2 19 d8 6a f0 33 2e
...
I can still see that you're talking to example.com and roughly how much data is sent, but not what is sent.
And if I flip even a single byte, the server notices and drops the connection.
That's the whole point of TLS: confidentiality (nobody can read it) and integrity (nobody can modify it).
But there's a third property that's easy to forget, and it's what the rest of this blog is about: authenticity.
Encryption is useless if you're encrypting your password and sending it straight to the attacker.
How does your browser know it's actually talking to example.com, and not to me pretending to be example.com?
How TLS Works
Before any real data is sent, the client and server do a handshake. Simplified, it goes like this:
- Client Hello: the browser says "Hi, I want to talk to
example.com, here are the encryption methods I support." - Server Hello: the server picks an encryption method and sends back its certificate.
- Certificate verification: the browser checks the certificate. Is it really for
example.com? Is it expired? Was it signed by someone I trust? - Key exchange: both sides agree on a shared secret key without ever sending the key itself over the network (using a clever bit of math called Diffie-Hellman).
- Encrypted traffic: from now on, everything is encrypted with that shared key.
Step 3 is where leaf, intermediate, and root certificates come in. The certificate the server sends is the leaf certificate.
It says "I am example.com, and here is my public key." But anyone can write a document that says "I am example.com". So the
leaf certificate is signed by an intermediate certificate, which is in turn signed by a root certificate.
Root CA (trusted by your device)
└── Intermediate CA (signed by the root)
└── example.com (leaf, signed by the intermediate)
This is called the chain of trust. Think of it like a reference letter: you don't know the person applying, but they bring a letter from their manager, and the manager's letter is signed by a company director you already trust.
You can see this chain yourself:
openssl s_client -connect example.com:443 -showcerts
The output lists the certificates the server sends, starting from the leaf (depth=0) and going up the chain.
Where is the Root Certificate?
If the root signs the intermediate, who signs the root? Nobody. The root signs itself (it's self-signed). So a root certificate can't be verified by a signature; it is trusted simply because it's already on your device.
Every operating system and browser ships with a trust store, a list of a few hundred root certificates it trusts:
- macOS: Keychain Access → System Roots
- Windows: the Certificate Manager (
certmgr.msc) - Linux: usually
/etc/ssl/certs - Firefox: its own store, maintained by Mozilla
Getting a root into these stores is hard. The CA has to pass audits and follow strict rules set by the CA/Browser Forum and each browser's root program. And because a root is so powerful, its private key is usually kept offline, locked in a hardware security module (HSM), and only taken out for rare ceremonies like signing a new intermediate.
That's actually why intermediates exist. The root stays offline and safe, while the intermediate does the day-to-day signing. If an intermediate gets compromised, it can be revoked and replaced without having to update the trust store on billions of devices.
How does CA work?
A Certificate Authority (CA) is the organization that owns these roots and intermediates, like Let's Encrypt, DigiCert, Sectigo, or eMudhra. Its job is basically to answer one question before issuing a certificate: does this person really control this domain?
For a typical certificate (called Domain Validated), the CA gives you a challenge, for example:
- put a specific file at
http://example.com/.well-known/acme-challenge/..., or - add a specific TXT record to your DNS.
Only the real owner of the domain can do that. Once the challenge passes, the CA signs your certificate with its intermediate's private key. Let's Encrypt automates this whole thing through a protocol called ACME, which is why tools like certbot or cert-manager in Kubernetes can renew certificates without any human involved.
CAs are also watched closely:
- Certificate Transparency (CT) logs: every certificate issued is published to public, append-only logs. If a CA issues a certificate for your domain that you didn't ask for, you can find it.
- Revocation: if a certificate's private key leaks, the CA can revoke it, and clients can check this via CRLs or OCSP.
- Distrust: if a CA keeps making mistakes, browsers can remove its root from their trust stores. That effectively kills every certificate it has issued, which is why incidents like the eMudhra one get taken so seriously.
How does leaf certificate work?
The leaf certificate is the one that actually belongs to the website. Inside it, you'll find:
- Subject Alternative Names (SAN): the domains it's valid for, e.g.
example.comandwww.example.com. - Public key: the server's public key. The matching private key never leaves the server.
- Validity period: a "not before" and "not after" date. These are getting shorter and shorter: the CA/Browser Forum has agreed to gradually cut the maximum lifetime down to 47 days by 2029, which pushes everyone towards automation.
- Issuer: which intermediate signed it.
- Signature: the intermediate's signature over all of the above.
When your browser receives it, it:
- Checks that the domain you typed is in the SAN list.
- Checks that today's date is within the validity period.
- Uses the intermediate's public key to verify the leaf's signature.
- Uses the root's public key (from the trust store) to verify the intermediate's signature.
- Optionally checks that none of them have been revoked.
If any step fails, you get that big red "Your connection is not private" page.
Finally, the server proves it actually owns the leaf certificate by signing part of the handshake with its private key.
That's the step that stops me, the attacker, from just copying example.com's public certificate and replaying it. I have the certificate, but not the private key, so I can't produce that signature.
Conclusion
TLS isn't just "encryption". It's encryption plus a way to know who you're encrypting for. That second part is built on a chain:
- The leaf says "I am this website, here's my key."
- The intermediate vouches for the leaf.
- The root, sitting in your device's trust store, vouches for the intermediate.
The whole system works only as long as CAs stay careful, which is why a mistake by a single CA is such a big deal. Next time you click the padlock icon in your browser, you can see this exact chain for yourself.