Notes
Three promises
TLS makes three promises. Confidentiality: nobody on the network path can read the data. Integrity: nobody can change it without being detected. Authentication: the client knows it is talking to the real server. It promises nothing about the endpoints themselves. A site with perfect TLS can still have SQL injection, and malware on a laptop reads data before it is encrypted. TLS protects data in transit, and only that.
- Confidentiality: nobody on the path can read the data
- Integrity: nobody can change it without detection
- Authentication: you are talking to the real server
- it does NOT protect: the endpoints, the application, or data once it arrives
Step 1: ClientHello
Step one, the client hello. The client lists the versions and cipher suites it supports, and, new in 1.3, it includes its key exchange value immediately instead of waiting. It also sends the server name it wants, called SNI, the application protocols it speaks, and a random value. This message is not encrypted. That is why a network observer can see which hostname you are connecting to, even though they cannot see the page.
- supported versions: TLS 1.3
- cipher suites it accepts
- a key share: its X25519 public value, sent at once
- SNI: the hostname it wants (visible to the network)
- ALPN: h2, http/1.1
- a random value
- sent in the clear
Step 2: ServerHello
Step two, the server hello. The server picks the version and one cipher suite, and replies with its own key exchange value. At this moment, both sides can compute the same shared secret, exactly as in the Diffie-Hellman episode, and derive handshake keys from it. From here on, everything is encrypted. In 1.3, that includes the server's certificate, which older versions sent in the clear for anyone to read.
- server chooses the version and one cipher suite
- sends its own key share
- both sides now compute the same shared secret (Diffie-Hellman, episode 6)
- HKDF derives handshake keys
- everything after this message is encrypted
Step 3: prove identity
Step three is identity. The server sends its certificate chain, then a message called certificate verify: a signature over the entire handshake so far, made with the certificate's private key. The client validates the chain and the hostname, then checks that signature. An attacker in the middle cannot produce it without the private key, and because it covers the whole transcript, they also cannot alter earlier messages, such as removing the strong ciphers.
- Certificate: the chain
- CertificateVerify: a signature over the whole handshake so far, made with the private key of the certificate
- Finished: a MAC over the transcript
- client validates the chain and the name (episode 8)
- this defeats man in the middle
Step 4: Finished
Step four. Both sides send a finished message, a check value proving they saw the same handshake. Application keys are derived, one for each direction, and data flows in records protected with AES in GCM mode or ChaCha twenty. The whole handshake takes one round trip, where TLS one point two needed two. And because the key exchange values were ephemeral and are now discarded, the session has forward secrecy.
- both send Finished; each confirms the same transcript
- application keys are derived: one per direction
- data flows as AES-GCM or ChaCha20-Poly1305 records
- total: 1 round trip (TLS 1.2 needed 2)
- ephemeral keys are discarded: forward secrecy
See it
Here is a real handshake, against a practice server on our own machine, using the certificate from the last episode. Read it top to bottom and you can name every part. Protocol: TLS 1.3. Cipher suite: AES two fifty six in GCM mode. The peer certificate and its name. The signature type: ECDSA. Verification: OK, because we supplied our practice root. And the temporary key: X two five five one nine. That one screen summarises this whole part of the course.
CONNECTION ESTABLISHED Protocol version: TLSv1.3 Ciphersuite: TLS_AES_256_GCM_SHA384 Peer certificate: CN = shop.example.test Hash used: SHA256 Signature type: ECDSA Verification: OK Server Temp Key: X25519, 253 bits
When verification fails
Now the same connection without telling the client about our root. Two verification errors, and then, connection established. The diagnostic tool carries on so you can inspect things, but a real client must stop at this point. This output shows something important: the connection is still encrypted with TLS 1.3, but you have no idea who is on the other end. Encryption without authentication protects nothing from an active attacker.
verify error:num=20:unable to get local issuer certificate verify error:num=21:unable to verify the first certificate CONNECTION ESTABLISHED Protocol version: TLSv1.3 # s_client carries on anyway; a real # client must stop here. Encrypted # is not the same as authenticated
What 1.3 removed
Much of the security of 1.3 comes from what it removed. Static RSA key exchange, which had no forward secrecy. CBC-mode ciphers, the source of years of padding oracle attacks. RC four, triple DES, MD five and SHA one. Compression, which leaked secrets. Renegotiation. Only five cipher suites remain, all of them authenticated encryption. And the handshake detects attempts to force a downgrade to an older version.
- static RSA key exchange (no forward secrecy)
- CBC-mode ciphers (padding oracle attacks)
- RC4, 3DES, MD5, SHA-1
- compression (CRIME)
- renegotiation
- only 5 cipher suites remain, all authenticated (AEAD)
- downgrade is detected
Attacks on older TLS
You do not need every old attack in detail, but know the themes. POODLE, BEAST and Lucky thirteen exploited CBC mode and SSL version three. Heartbleed was a bug in the OpenSSL library that leaked server memory, including keys. FREAK and Logjam forced connections down to weak keys. And SSL stripping keeps the user on plain HTTP so TLS never starts. The fixes: allow only TLS one point two and above, patch the library, and enable HSTS.
- POODLE, BEAST, Lucky13: CBC and SSLv3 weaknesses
- Heartbleed: an OpenSSL bug leaked server memory
- FREAK, Logjam: downgrade to weak "export" keys
- SSL stripping: user never reaches HTTPS at all fix: TLS 1.2+ only, patch the library, HSTS
0-RTT and mTLS
Two features have security consequences. Zero round trip resumption lets a returning client send data with its very first message. It is faster, but that early data can be captured and replayed by an attacker, so allow it only for requests that are safe to repeat, never for a payment. And mutual TLS: the client also presents a certificate, so both sides are authenticated. It is the standard way for services to prove identity to each other inside a zero trust network.
- 0-RTT: a returning client sends data with its first message; faster, but an attacker can replay it
- allow it only for safe, repeatable requests (GET)
- mTLS: the client also shows a certificate; both sides are authenticated
- used between services
Harden it
The hardening checklist. Allow TLS 1.3 and one point two only. For one point two, permit only suites with ephemeral key exchange and authenticated encryption. Serve the full certificate chain and automate renewal. Send the HSTS header so browsers refuse plain HTTP. Keep the TLS library patched. Encrypt internal traffic as well, not only the public edge. Test with testssl or sslyze on systems you own, and monitor certificate expiry.
- TLS 1.3 and 1.2 only 1.2: ECDHE + AEAD suites only full chain served; automated renewal
- HSTS header (with preload for public sites)
- keep the TLS library patched
- internal traffic encrypted too
- test: testssl.sh, sslyze, SSL Labs
- monitor certificate expiry
Common mistakes
Mistakes. Certificate verification disabled in clients, which removes authentication completely. TLS one point zero or one point one still enabled for one old client. TLS that ends at the load balancer, with plain HTTP across the internal network. No HSTS. Zero round trip data accepted on requests that change state. An unpatched TLS library. And believing that a padlock means a site is secure, when it only means the connection is.
- certificate checks disabled in clients
- TLS 1.0 or 1.1 still on
- TLS ends at the load balancer; plain HTTP behind
- no HSTS
- 0-RTT on state-changing requests
- an unpatched TLS library
- "it has a padlock, so it is secure"
Say it like this
In the interview: the client hello carries supported versions, cipher suites and a key share, usually X two five five one nine. The server hello returns its key share, and both derive handshake keys with HKDF. The server then sends, encrypted, its certificate, a signature over the transcript to prove it holds the private key, and finished. The client validates the chain and name. One round trip, then AEAD-protected data with forward secrecy.
- "ClientHello carries versions, ciphers and an X25519 share.
- ServerHello returns its share;
- both derive keys with HKDF.
- Encrypted: the certificate, a signature over the transcript, Finished. One round trip, then AEAD records, with forward
- secrecy."