learning-it by example

Back to the video

How HTTPS Works: Watch a TLS 1.3 Handshake in Python

In a TLS 1.3 handshake, every handshake message after the two hellos is encrypted, but the site name is not.

Video #280 ยท How it works, by example

Steps in the video

  1. 0:00 Watch a TLS 1.3 handshake
  2. 0:32 The idea
  3. 1:07 Setup
  4. 1:33 A throwaway certificate
  5. 2:05 Reading the records
  6. 2:36 The name in plain sight
  7. 3:07 A handshake with no network
  8. 3:38 Run it
  9. 4:57 What this does not show
  10. 5:28 Mistakes to avoid
  11. 6:07 My take and next steps
  12. 6:28 Recap

Files

  • local_server.py (23 lines)
  • make_cert.py (25 lines)
  • pump.py (27 lines)
  • run.py (37 lines)
  • watch.py (38 lines)

Download the code (zip)

Tested with

Python 3.12.15 | cryptography==50.0.2

What this does not show

One handshake in memory on one machine, with a throwaway self-signed certificate; it names record types only and does not show certificate chains, session resumption or Encrypted Client Hello.

Sources

Learning IT by Example.