Skip to content
subuilds.dev

← logbuild #25 passed5065f64

The TLS Foundation

What TLS does and how the chain of trust works. Also why your browser carries the public key of every CA in the world, but never the private keys.

· 11 min read

Think of a postcard that you send by mail. Everyone who touches it on the way can read the back: the postal worker at pickup, the sorter, the carrier. That’s the regular internet without TLS.

Now put that postcard into a locked metal box. Only the person you send it to has the key. If someone steals the box on the way, they still can’t see inside. That’s TLS.

This post is the foundation. No OpenSSL, no hands-on work. At the end you’ll know what TLS does and how your browser decides who to trust. You’ll also know what every operating system on earth ships, and why the whole system rests on one mathematical asymmetry. Each section takes two minutes. Read from top to bottom.

In Simple Words#

The problem
Without TLS, your data travels like a postcard. Anyone on the path can read it or change it. You also cannot be sure that the server is the real one.
The root cause
On the internet, your data crosses a path that other people can access. And you never meet the server in person, so you cannot hand it a key or check who it is.
The solution
TLS does three jobs: it encrypts the data, checks who the server is, and seals the data against changes. Your browser checks every site’s certificate against a list of trusted roots.
Think of it like this
A king seals his letters with a ring that only he has. Everyone knows what the seal looks like, so everyone can check a letter. But nobody can make the seal without the ring. The ring is the private key. The look of the seal is the public key.

What We’ll Cover#

  1. TLS in one image
  2. The three jobs TLS does
  3. How you know it’s on
  4. SSL vs TLS — the name confusion
  5. How authentication works — the chain of trust
  6. The TLS handshake, step by step
  7. Two crypto types, two jobs
  8. What your browser actually ships
  9. The asymmetry that makes everything work

1. TLS in One Image#

Postcard versus locked box An animation showing the same message sent two ways. First, an open postcard travels across the network and a snooper in the middle reads its contents. Then, the same postcard travels inside a locked metal box; the snooper sees only scrambled characters. You browser Server example.com snooper password: hunter2 ▓▓▓▓▓▓▓▓ Without TLS — anyone on the path can read your message With TLS — only the recipient can open the box

Without TLS, your data on the internet is a postcard. The mailman reads it. The sorting worker reads it. Anyone with access to the path between you and the destination reads it.

With TLS, the postcard is inside a locked metal box. The recipient holds the only key that fits. The carriers still move the box from sender to receiver, but none of them can see inside.

That’s the picture. Everything below explains how the box works over a network. The hard part: you never meet the recipient in person to hand them a key.

2. The Three Jobs TLS Does#

TLS does exactly three things when your computer talks to a server:

Job The postcard analogy What it stops
Encryption The locked box — only the recipient can open it Eavesdropping (reading the data in transit)
Authentication Verifying the box really belongs to the recipient Impersonation (talking to a fake server)
Integrity A tamper-proof seal on the box Tampering (someone editing the data in transit)

Encryption is the easy half. Both ends agree on a scrambling rule and use it. The really hard half is authentication. You must know that the “recipient” on the other end is really who they say they are. The rest of this post is about that one problem.

3. How You Know It’s On#

You don’t have to read the protocol to know that TLS is working. Your browser tells you:

  • 🔒 padlock icon + https:// — TLS is on. The conversation is encrypted and the browser has checked the server’s identity.
  • ⚠️ “Not secure” + http:// — no TLS. Anyone in the path can read and change the traffic.

The “S” in HTTPS stands for Secure. It means TLS does the work below HTTP. When your browser shows a green padlock, three things have already happened in the background. A certificate was checked. The two sides agreed on a key. The traffic switched to encrypted mode. The rest of this post explains how.

4. SSL vs TLS — The Name Confusion#

You’ll see both names. They mean the same thing in different generations.

  • SSL was the original (1990s). The last version, SSL 3.0, had real vulnerabilities (security holes) and was retired years ago.
  • TLS replaced it. Current versions are TLS 1.2 (2008) and TLS 1.3 (2018, what almost everything uses now).

People still say “SSL” out of habit. If a vendor sells you an “SSL certificate” in 2026, it’s a TLS certificate. The name is old, but the protocol has moved on.

5. How Authentication Works — The Chain of Trust#

This is the most important part of TLS. Your browser connects to bank.example.com. How does it know that it is talking to the real bank? An attacker on the same Wi-Fi could set up a server that looks the same.

The answer is a chain of trust. Your browser and operating system come with a list of root certificates already installed: DigiCert, Let’s Encrypt, GoDaddy, and roughly 150 others. Each root belongs to a certificate authority (CA), an organization that signs certificates. This list is called the trust store. In the end, the identity of every site leads back to one of these roots.

But root CAs don’t sign sites directly. Roots stay offline in physical vaults. They sign intermediate CAs, and the intermediates do the daily work of signing real websites.

Chain of trust verification An animation showing a browser verifying a website's certificate by walking the chain upward: leaf cert to intermediate CA to root CA, then matching the root against the browser's pre-installed trust store. Browser trust store ~150 pre-installed roots DigiCert GlobalSign Let's Encrypt Let's Encrypt ISRG Root X1 (offline) Let's Encrypt R3 intermediate, signs daily example.com the website's cert Verifying example.com's certificate… Chain ends at a trusted root — example.com is trusted.

When you visit example.com, the server sends back its own certificate plus any intermediate certificates needed to complete the chain. Your browser walks up the chain: leaf → intermediate → root. It checks each signature until it reaches a root it already trusts.

Why the extra layer? Imagine that a root CA’s private key leaks. Every certificate that CA ever signed would become invalid overnight. So roots stay offline, and intermediates do the daily signing. If an intermediate is compromised, it can be revoked (cancelled) without destroying the whole trust tree. The system is built to survive when one part of it is broken into.

6. The TLS Handshake, Step by Step#

Here’s what happens in the first ~100 milliseconds when your browser opens an HTTPS site:

TLS handshake An animation of a TLS handshake. The browser and server exchange ClientHello, ServerHello with certificate, then the browser verifies the certificate, both sides run Diffie-Hellman to derive a shared key, and the connection switches to symmetric encryption. Your browser example.com Server TLS 1.3 ClientHello versions, ciphers, random ServerHello + Cert picked cipher, cert chain browser half server half shared session key 🔒 🔒 🔒 🔒 1. ClientHello — versions, ciphers, random 2. ServerHello + Certificate — chain sent back 3. Browser verifies the cert chain 4. Diffie-Hellman — both sides derive the same key 5. Switch to AES — encrypted data flows TLS handshake Secure channel established

In words:

  1. ClientHello — your browser tells the server which TLS versions and cipher suites it supports, and sends a random number. A cipher suite is a set of encryption methods.
  2. ServerHello + Certificate — the server picks a version and a cipher. It sends its random number and its full certificate chain.
  3. Verify the cert — your browser walks the chain. Is the signature valid? Is the cert in date? Does the name in the cert match the hostname you typed? Has it been revoked (OCSP or CRL)? If any check fails, you get the “not secure” warning.
  4. Key exchange — both sides run a Diffie-Hellman exchange. The clever part: both ends arrive at the same shared secret key, but the key itself never travels over the network. An attacker who records every byte still cannot work it out.
  5. Switch to symmetric — both sides now hold the same key. They stop using the slow asymmetric crypto and switch to fast symmetric encryption (AES) for the real data.

Steps 1–4 are the handshake. Step 5 is the encrypted conversation. The handshake takes a few milliseconds and happens once per connection.

7. Two Crypto Types, Two Jobs#

That last point is more important than it sounds. TLS uses two different kinds of cryptography. Each one does the job it is good at.

Type Examples Used for Why
Asymmetric RSA, ECDSA Handshake, signing certs Solves the “how do we share a key” problem
Symmetric AES, ChaCha20 Encrypting the actual data 100–1000× faster than asymmetric

Asymmetric crypto has a special property: a public key can verify what a private key signed. That’s how identity works. But it’s slow and expensive. Symmetric crypto is fast and cheap, but both sides need the same key. And that is exactly the problem the asymmetric handshake has just solved.

TLS uses the slow half, which is good for identity, to start the fast half, which is good for large amounts of data. Identity first, speed second.

8. What Your Browser Actually Ships#

A natural question comes after all this. Your OS and browser ship with “certificates” from DigiCert, Let’s Encrypt and GoDaddy. Did those companies hand over their secrets, to be put into every Chrome install on earth?

No. And this is the most important idea in public-key cryptography.

Public keys ship, private keys stay in the vault An animation showing a Certificate Authority's private key locked in a vault. A blank certificate enters the vault, gets stamped with a wax seal, and exits. Every device on the right already has a copy of the seal pattern (the public key) and can verify the signature without ever holding the private key. CA's vault The world A1 Private key never leaves Laptop A1 Phone A1 Runner A1 A1 Sign with private — the CA stamps the cert inside the vault. Ship public — every device knows the seal pattern. Verify with public — the ring never leaves the vault.

What’s shipped is each CA’s public key, inside a public certificate. The private key never leaves the CA. It sits in a hardware security module, in a vault. Often several people are needed to access it.

Key Who has it What it does
Public key Everyone (shipped in your browser) Verifies signatures
Private key Only the CA — locked in a vault Signs certificates

Anyone with the public key can verify a signature. But nobody can forge (fake) a signature without the matching private key, even with the public key. It works in one direction only.

Think of a king’s wax seal in the Middle Ages. The king has a unique signet ring. That’s the private key, kept under guard. Everyone in the kingdom knows what the king’s seal looks like. That’s the public key, shared openly. When a letter arrives with the seal pressed into the wax, anyone can check that it’s real. But nobody can forge the seal without the ring.

Shipping CA public keys to every browser is the same trick. Every device in the world learns what the seal looks like, and the ring is never at risk.

9. The Asymmetry That Makes Everything Work#

Reduce TLS to the one idea you’d keep if you forgot everything else:

  • Public keys are everywhere. They verify. Losing one costs nothing.
  • Private keys exist only where they belong. They sign. Losing one is a disaster.

That asymmetry is simple: verify with the public key, sign with the private key. It is the building block below TLS, SSH, code signing, package signing, and every crypto wallet you’ve ever heard of. The protocols differ, but the trick below them is the same one.

When you see the padlock in your browser, it really means one thing. The server proved it holds a private key, and someone my browser already trusts signed the public half. That one sentence is the whole foundation.

What You Have Now#

Concept The takeaway
TLS in one image The locked box, not the postcard
The three jobs Encryption, authentication, integrity
The chain of trust Roots stay offline; intermediates sign daily; your browser walks the chain to a root
The handshake Asymmetric to bootstrap a key; symmetric for the actual data
The big asymmetry Public keys verify, private keys sign — the private half never moves

You now have the mental model. Everything else is a variation on these same ideas: internal CAs, certificate transparency, mTLS, OCSP stapling.

Next Steps#

  • Self-Host Harbor Image Registry on Debian — use what you learned here. Build your own CA, sign certs for an internal registry, and connect it to a GitLab Runner from start to end.
  • Linux Server Security Baseline — for when you become your own CA. The host that holds the private key is then the most powerful machine on your network. Harden it to match.