Security and remote accessBetween TCP and the applicationRFC 8446 (TLS 1.3)
HTTPS and TLS: the secure handshake
How a browser and a server agree on a secret key and prove who the server is, in one round trip.
Ports and use: TCP 443
In one sentenceTLS lets two computers create a shared secret in public, check the server's identity, and then encrypt everything.
Think of it like thisIt is two people mixing paint colours in public: each adds a private colour, and they end with the same shade that no onlooker can work out.
Watch it happen
5 steps and 2 byte-by-byte decodes. Use the buttons or the arrow keys. Hover or focus a field to find its bytes.
- Browser
- Web server
- ClientHelloBrowser to Web server
- ServerHelloWeb server to Browser
- Certificate and Finished (encrypted)Web server to Browser
- Client FinishedBrowser to Web server
- Application dataBrowser to Web server
Step 1 of 5 ClientHello
Browser → Web server
After TCP connects, the browser sends what it supports and its half of a key exchange.
ClientHello record 179 bytes
16 03 01 00 ae 01 00 00 aa 03 03 30 52 c8 a3 e0 ed f2 64 37 bd 20 36 42 a6 78 55 56 67 84 1c 61 de 23 ac 53 71 cc 88 7d dd a0 cc 20 b9 5d 76 c8 6d 63 34 b0 e4 8a 49 ea d5 65 a9 e0 b0 44 6a 90 ee d6 57 c5 84 51 ed a1 39 00 8e cf 00 06 13 01 13 02 13 03 01 00 00 5b 00 00 00 10 00 0e 00 00 0b 65 78 61 6d 70 6c 65 2e 63 6f 6d 00 0a 00 06 00 04 00 1d 00 17 00 0d 00 08 00 06 04 03 08 04 04 01 00 2b 00 03 02 03 04 00 33 00 26 00 24 00 1d 00 20 a3 c9 8a 8f 79 70 be 11 75 99 8c f3 3d 94 68 d0 a0 d6 e1 fb 0b 42 07 db 44 59 fe 77 63 dc db bd
| Field | Bytes | What it means |
|---|---|---|
| Record type | 16 | 0x16 (22) means a handshake record. |
| Record version | 03 01 | 0x0301 is a legacy value kept so old equipment does not reject the record. |
| Record length | 00 ae | The handshake message that follows is 174 bytes. |
| Handshake type | 01 | 1 means ClientHello. |
| Handshake length | 00 00 aa | 170 bytes of body. |
| Client version | 03 03 | 0x0303 is another legacy value. The real version is in the supported versions extension. |
| Random | 30 52 c8 a3 e0 ed f2 64 37 bd 20 36 42 a6 78 55 56 67 84 1c 61 de 23 ac 53 71 cc 88 7d dd a0 cc | 32 bytes the browser makes up for this connection. These bytes are an example. |
| Session ID length | 20 | 32 bytes follow. |
| Session ID | b9 5d 76 c8 6d 63 34 b0 e4 8a 49 ea d5 65 a9 e0 b0 44 6a 90 ee d6 57 c5 84 51 ed a1 39 00 8e cf | A legacy field TLS 1.3 keeps for compatibility. |
| Cipher suites length | 00 06 | Three cipher suites, 2 bytes each. |
| Cipher suites | 13 01 13 02 13 03 | 1301 is AES-128-GCM, 1302 is AES-256-GCM and 1303 is ChaCha20-Poly1305. The server picks one. |
| Compression methods | 01 00 | One method, "none". TLS 1.3 does not compress. |
| Extensions length | 00 5b | 91 bytes of extensions follow. |
| Extension: server name | 00 00 00 10 00 0e 00 00 0b 65 78 61 6d 70 6c 65 2e 63 6f 6d | Server Name Indication: the site the browser wants (example.com), sent in the clear so a server with many sites can pick the right certificate. |
| Extension: supported groups | 00 0a 00 06 00 04 00 1d 00 17 | Key-exchange curves the browser can use: x25519 (001d) and secp256r1 (0017). |
| Extension: signature algorithms | 00 0d 00 08 00 06 04 03 08 04 04 01 | How the browser can check the server's signature: ECDSA, RSA-PSS and RSA. |
| Extension: supported versions | 00 2b 00 03 02 03 04 | The browser supports TLS 1.3 (0304). |
| Extension: key share | 00 33 00 26 00 24 00 1d 00 20 a3 c9 8a 8f 79 70 be 11 75 99 8c f3 3d 94 68 d0 a0 d6 e1 fb 0b 42 07 db 44 59 fe 77 63 dc db bd | The browser's half of the key exchange for x25519: 32 bytes. These bytes are an example, not a real key. |
Step 2 of 5 ServerHello
Web server → Browser
The server chooses TLS 1.3 and a cipher suite and sends its half of the key exchange. Both sides can now work out the same secret, and everything after this message is encrypted.
ServerHello record 127 bytes
16 03 03 00 7a 02 00 00 76 03 03 d5 d0 fa 01 e3 c9 e1 66 0a 92 a5 0a fb 30 95 0f 5c 3a ac 25 c0 d0 22 4b c7 44 38 ec 7b 64 01 5e 20 b9 5d 76 c8 6d 63 34 b0 e4 8a 49 ea d5 65 a9 e0 b0 44 6a 90 ee d6 57 c5 84 51 ed a1 39 00 8e cf 13 01 00 00 2e 00 2b 00 02 03 04 00 33 00 24 00 1d 00 20 5c 8b 16 b3 a0 1b 74 86 e7 44 8a e2 55 ad 3a 52 f5 c5 8d 3d a9 02 ca f0 19 f2 78 de ae 74 29 51
| Field | Bytes | What it means |
|---|---|---|
| Record type | 16 | A handshake record again. |
| Record version | 03 03 | 0x0303: the legacy version value. |
| Record length | 00 7a | 122 bytes follow. |
| Handshake type | 02 | 2 means ServerHello. |
| Handshake length | 00 00 76 | 118 bytes of body. |
| Server version | 03 03 | Legacy value 0x0303. |
| Random | d5 d0 fa 01 e3 c9 e1 66 0a 92 a5 0a fb 30 95 0f 5c 3a ac 25 c0 d0 22 4b c7 44 38 ec 7b 64 01 5e | 32 bytes the server makes up. These bytes are an example. |
| Session ID length | 20 | 32 bytes follow. |
| Session ID echo | b9 5d 76 c8 6d 63 34 b0 e4 8a 49 ea d5 65 a9 e0 b0 44 6a 90 ee d6 57 c5 84 51 ed a1 39 00 8e cf | The server copies the browser's session ID back. |
| Chosen cipher suite | 13 01 | 1301: the server chose AES-128-GCM with SHA-256. |
| Compression | 00 | None. |
| Extensions length | 00 2e | 46 bytes follow. |
| Extension: supported versions | 00 2b 00 02 03 04 | The server agrees to use TLS 1.3. |
| Extension: key share | 00 33 00 24 00 1d 00 20 5c 8b 16 b3 a0 1b 74 86 e7 44 8a e2 55 ad 3a 52 f5 c5 8d 3d a9 02 ca f0 19 f2 78 de ae 74 29 51 | The server's half of the key exchange. Both sides now compute the same secret without ever sending it. These bytes are an example. |
Step 3 of 5 Certificate and Finished (encrypted)
Web server → Browser
Still in the same flight, the server sends its certificate, a signature proving it holds the matching private key, and a Finished message. An observer sees only encrypted bytes.
Step 4 of 5 Client Finished
Browser → Web server
The browser checks the certificate against the trusted authorities and the site name, verifies the signature, and sends its own Finished message.
Step 5 of 5 Application data
Browser → Web server
The browser sends the HTTP request, now encrypted. Nobody in between can read or change it without being noticed.
Where you meet it
- Every website with a padlock, including banking, shopping and login pages.
- APIs, email servers and databases that must protect data on the network.
- Anywhere a certificate is checked: HTTPS, mail (SMTPS, IMAPS), and VPNs built on TLS.
Common mistakes
- Ignoring certificate warnings. They often mean the connection is being intercepted.
- Letting a certificate expire. Browsers then refuse to connect.
- Serving some assets over plain HTTP on an HTTPS page, which causes "mixed content" problems.
- Thinking HTTPS hides which site you visit. The site name is still visible, although Encrypted Client Hello is starting to change that.
Try it yourself
Run these on your own computer and compare the output with the lesson above.
openssl s_client -connect example.com:443 -servername example.com -tls1_3 </dev/nullShows the handshake and the certificate chain.curl -vI https://example.com/Look for the TLS lines before the HTTP headers.
Addresses and values in the examples are made up for teaching (the 203.0.113.x range is reserved for documentation). Real traffic carries more options and details. Check the standard named above for the full rules.