/Learn
09 · Application · TCP 443

HTTPS

HTTP over TLS

HTTP inside a TLS tunnel.

LearnProtocolTier 2 · MechanismsUnderstand10 minInfrastructure

You will be able to: trace a HTTPS exchange and decode it byte by byte.

Prove it: Ray Serve Distributed Actor Deployment

System designProtocols

Study with AI

Part 1 of 5

Basics

What the protocol is for, and the ideas it is built on.

1.1What it does

The protocol in plain words, before any bytes.

HTTPS is not a new protocol. It is ordinary HTTP carried inside a TLS connection. First TCP connects, then TLS handshakes, then the browser sends the same requests you saw in the HTTP lesson, but encrypted.

An observer on the network can see the destination address, roughly how much data moves and (unless ECH is used) the server name. They cannot see the path, headers, cookies or body.

1.2Key ideas

The handful of ideas everything else follows from.

Round trips add up

TCP + TLS 1.3 costs two round trips before the first request. HTTP/3 over QUIC folds this into one.

HSTS

A header that tells browsers to use HTTPS only for a site, preventing downgrade attacks.

What is visible

IP addresses, timing, size and SNI. Not URLs, headers or content.

Mixed content

An HTTPS page that loads a script over HTTP lets an attacker modify the page. Browsers block it.

Part 2 of 5

Question

What this lesson prepares you to answer. Keep these in mind while you watch the packets.

2.1Target questions

  1. Can your ISP see which pages you visit on HTTPS?
  2. Why is HTTPS slower to start than HTTP?

The answers are in part 4.

Part 3 of 5

Detailed answer

Watch a real exchange step by step, then take each message apart field by field.

3.1Follow the packets

Step through the exchange between the two sides.

Browser
Server
TCP handshake
TLS ClientHello
TLS ServerHello … Finished
Encrypted GET /
Encrypted 200 OK
Step 1 of 5

SYN, SYN-ACK, ACK: one round trip.

3.2Decode it byte by byte

Click any byte or row. Each colour is one field.

After the handshake, HTTP is sent inside TLS application-data records. On the wire this is all an observer sees. Bytes are illustrative.

00001703030024135ca5ee3780c9125ba4ed····$·\··7···[··
0010367fc8115aa3ec357e638cb5de0730596···Z··5~c····0Y
002082abd4fd264f78a1ca····&Ox··
FieldRecord type
Length1 byte
Decimal23

23 = Application data. TLS 1.3 always uses this outer type, even for encrypted handshake messages.

FieldOffsetBytesHex
Record type0117
Record version1203 03
Record length3200 24
Ciphertext52013 5c a5 ee 37 80 c9 12 …
Authentication tag251663 8c b5 de 07 30 59 82 …

3.3Decode it in code

A small decoder, tested against the exact bytes shown above.

What an observer sees in HTTPS

An encrypted record has a small visible header, then opaque bytes.

https.tsTypeScript
1/** Outside the tunnel an observer sees this much, and nothing more. */2export function parseRecord(b: Uint8Array) {3  const view = new DataView(b.buffer, b.byteOffset, b.byteLength);4  const length = view.getUint16(3);5  const body = b.subarray(5, 5 + length);6  return {7    type: b[0], // 23 means application data8    length,9    ciphertext: body.subarray(0, -16),10    tag: body.subarray(-16), // the AEAD tag proves nobody changed the data11  };12}13 14/** TLS 1.3: each record's nonce is the fixed IV XOR its sequence number. A nonce never repeats. */15export function recordNonce(iv: Uint8Array, seq: bigint): Uint8Array {16  const nonce = iv.slice();17  for (let i = 0; i < 8; i++) nonce[nonce.length - 1 - i] ^= Number((seq >> BigInt(8 * i)) & 0xffn);18  return nonce;19}
19 linesUTF-8TypeScript
body.subarray(-16)
The AEAD tag. A changed byte makes decryption fail.
recordNonce
XORs a counter into the IV, so a nonce never repeats. Reusing one would break the encryption.

Tested by npm run test:modules.

Part 4 of 5

Q&A

Check your understanding. Answer out loud, then open.

4.1Check yourself

Can your ISP see which pages you visit on HTTPS?
Not the paths. It sees the IP and usually the domain through SNI.
Why is HTTPS slower to start than HTTP?
Extra handshake round trips and cryptographic work. Connection reuse and resumption reduce the cost.
Part 5 of 5

Extra depth

The mistakes people make with this protocol in real systems.

5.1Watch out for

  • A padlock means the connection is private, not that the site is trustworthy.
  • Certificates expire. Automate renewal.
  • Corporate proxies that inspect HTTPS install their own root certificate.
← HTTPSMTP →
AI Engineer · Protocol Explorer