What HTTPS adds on top of HTTP
The TLS handshake, certificates and the chain of trust behind them, what a man in the middle can and cannot do, and why forward secrecy changes what a stolen key is worth.
HTTP is text in the clear. Everything you type into a form, every session cookie and every API token travels as readable bytes, and any device on the path can not only read them but change them without either side noticing. HTTPS is the same HTTP, carried inside TLS. The interesting part is not the encryption — it is that both ends can agree on a secret key while an attacker hears every single message of the negotiation.
The handshake is that negotiation, and it happens before any request. The client opens a TCP connection, then sends a ClientHello containing a random number, the list of cipher suites it supports and a public key share. The server answers with its own random, its chosen suite and its key share. Both sides then derive the same session keys from their own private value and the other side public value, and nobody listening to the conversation can repeat that computation. At the end both send a Finished message that is a hash of everything said so far, so any modification during the handshake breaks the check immediately.
A certificate is a signed statement that binds a public key to a hostname. It contains the name, the public key, a validity window and a signature made by a certificate authority. That signature is what makes the key trustworthy — not the key itself, which proves nothing on its own. If you accept any key that is offered, an attacker simply offers their own.
Chain
1 leaf CN=example.org
SAN: example.org, www.example.org
valid 2026-01-01 .. 2026-04-01
2 intern CN=R3 Intermediate CA
3 root CN=ISRG Root X1 (already on the device)
Validation
signature of 1 checked with public key of 2 ok
signature of 2 checked with public key of 3 ok
signature of 3 checked with public key on device ok
name in SAN matches the host that was requested ok
current time inside the validity window okA certificate chain and the five checks a client performs.The chain is what makes a small number of roots enough for the whole web. A root authority signs an intermediate, the intermediate signs the certificate you receive, and your device only has to already trust the root — root certificates ship with the operating system and the browser. Validation walks the chain upwards: check the leaf signature with the intermediate key, check the intermediate with the root, check that the root is one you trust, then check that the name in the certificate matches the host you actually asked for and that today falls inside the validity window. Any single failure stops the connection.
An attacker on the path who cannot produce a valid certificate has a real problem. They can drop or delay your packets, they can impersonate an address, but they cannot read the encrypted bytes and they cannot forge the handshake without a certificate your client accepts. Changing one encrypted byte does not flip a bit in the plaintext — it fails authentication and the connection ends. This is why clicking through a certificate warning is a bad idea: either the warning is a genuine misconfiguration, or you have just handed your session to the person who caused it.
$ curl -v https://example.org
* SSL certificate problem: self-signed certificate in certificate chain
* Closing connection
$ curl -vk https://example.org
* Server certificate: CN=mitm-proxy.local
* subjectAltName does not match example.org
< HTTP/1.1 200 OKThe same request with and without certificate checking.Forward secrecy answers a specific question: what happens to traffic that was recorded years ago, if the server private key leaks today? In the classic key exchange the session key was encrypted with the server public key, so a recorded handshake plus the leaked private key is enough to decrypt everything. With ephemeral Diffie-Hellman the key share is generated fresh for this one connection and thrown away afterwards, so a later key leak is useless against past traffic. It does not make an active attacker weaker, and it does not help if the attacker already holds the session key. It changes the value of a stolen key from all history to one session.
Practice
Order the events of a first HTTPS request to a host you have never contacted.
- 1the encrypted HTTP request and response are exchanged
- 2the server presents its certificate chain
- 3the client sends a ClientHello with random data and a key share
- 4the client opens a TCP connection to port 443
- 5both sides finish the handshake and derive the same session keys
- 6the server replies with its own random, its chosen cipher and its key share
Hints
- Nothing encrypted can be sent before both sides have agreed how to encrypt it.
- The certificate arrives from the server after the two hello messages have been exchanged.
- Application data is the very last thing: the handshake must be finished on both sides first.
A server presents a certificate that was issued by a trusted authority for the correct hostname, but it expired three days ago. The browser refuses to connect. What does that refusal actually mean?
Hints
- Ask what the certificate proves: it is a signature by an authority, not a promise about the server software.
- A certificate with a perfectly valid signature can still be for a different hostname than the one you typed.
- An expired or revoked certificate is a normal, expected rejection, and the browser reports it loudly.
Match each attacker or failure with what they can actually achieve against a modern HTTPS connection.
Hints
- Separate the attackers by what they can do: read and change bytes, or merely copy them and wait.
- Forward secrecy is about traffic recorded long ago and decrypted much later, after a key has leaked.
- A passive observer on the path still learns the names of the sites you visit, even though the page contents stay hidden.
Questions about this lesson
Why should I learn networking at all?
Almost everything you build eventually talks to something else. Knowing how data actually travels turns "it does not work" from a mystery into a list of things you can check one by one.
What is the real difference between TCP and UDP?
TCP makes sure every piece arrives, in order, and retries anything lost — which costs time. UDP sends and does not look back, which is why live video and games prefer it: a late frame is worse than a missing one.
What is DNS in plain words?
It is the phone book of the internet. You know the name, the computer needs the number. DNS turns a name like example.org into an IP address, and caches the answer so it does not ask every time.
Is it free?
Yes. The first level of every subject is free and needs no account. Deeper levels and the senior grades are paid — that is what keeps the project running.
What age is this for?
It is written for curious teenagers from about 12 and for adults starting from zero. Nothing assumes prior programming experience; lessons about networking and physics need no mathematics beyond school level.
Do I need to know programming already?
No. The logic, physics and networking tracks start from nothing. The languages track is where you actually write code, and it also starts from the beginning.
Do I need to install anything?
No. Everything runs in the browser: theory, practice and the interactive simulations. There is nothing to download and no environment to configure.
How long does one subject take?
A lesson takes 10 to 15 minutes. A junior grade is roughly 12 to 20 lessons, so expect a few weeks of steady practice rather than one evening.
Do I have to follow the order?
Within a grade, levels open one after another, because each builds on the previous one. Between subjects you are free: start with logic, physics or networking.