Lesson 31 showed you that data in transit needs a lock. This lesson is the lock itself. A browser and a server meet as strangers, and in a few hundred milliseconds they agree on a secret, prove who the server is, and start talking in a code no one else can read. That meeting is the TLS handshake. By the end you will have watched one happen, read its version and its cipher, and said no to a server that only speaks the old, broken versions.
Difficulty: Basic · Know this first: Lesson 31 - Data in Transit and at Rest
Every hop charges rent in milliseconds. The bar below is a worked example for this lesson's scenario — not a measurement from a live system — but the shape is honest: on a cache hit the trip is almost free, on a miss the kitchen eats the budget. Step through the lesson or switch the scenario and watch the bar change.
Extra diagram · from scratch to master
Start with a name and a browser. Add one step at a time until the answer comes back through the lock.
The budget bar above shows three fixed stories. This simulator lets you write your own. Move a slider and watch the hello, the keys, and the answer change in the budget bar, in the hop timings, and in the total. The numbers are a teaching example, not live measurements. The shape is the lesson: the round trip and the number of fresh handshakes decide how slow the lock feels.
One round trip on the wire. A nearby server is about 10 to 30 ms. A far server is 150 ms or more, and every handshake round trip pays it.
A page opens several connections: the page, the style sheet, the scripts, the images. Every new connection pays the handshake again.
Share of connections that resume an old session instead of a fresh handshake. A resumed session skips the hello and the key exchange.
Try this: (1) Set round trip to 200, connections to 20, reuse to 0. The hello is about 4000 ms, the keys about 4000 ms, the answer about 4000 ms, and the total is about 12060 ms. (2) Set round trip to 10, connections to 1, reuse to 100. The hello is about 0 ms, the keys about 0 ms, the answer about 10 ms, and the total is about 70 ms. Same page. Only the network and the reuse changed.
Three questions. No score is saved anywhere — this is just you against the material.
Here is the one command that splits a visit into its stages. Change it, then run the check. The check looks for the seven parts a timing command needs: curl, throw the body away, the write-out flag, the lookup timer, the handshake timer, the total timer, and a locked address.
Try breaking it on purpose: delete the tls line from the format, or change https to http. Run the check and watch it fail. Then press Reset and try a change that keeps it passing, like adding a second site to time.
Expected output when it passes: The command times every stage: lookup, connect, handshake, first byte, and total. Run it and read the tls line. That line is the handshake cost.
I take the same trip four times here. First I learn what the lock is. Then I learn the versions and what changed. Then I learn to read a handshake. Last I run it for the world.
Definition: TLS is the lock on the wire. It proves the server is who it says it is, it scrambles the data so only the two ends can read it, and it stamps every piece so tampering shows. The handshake is the short meeting at the start where the two sides agree on a version, check a certificate, and make a shared secret. HTTPS is HTTP inside that lock.
Types:
Uses: I use this for every page I open and every API I call. Try it now: open a site you use every day, click the padlock, and read the panel. Then run the timing command from the Try it box and find the tls line. Practice reading handshakes in the TLS labs.
Dimensions: At low traffic everything is nearly free. What breaks first is trust: a certificate for the wrong name, a date that passed, or a server that only speaks an old version. It costs one careful read of the padlock panel, which always names the problem.
Definition: SSL was the first lock. SSL 2.0 came in 1995 and SSL 3.0 in 1996, and both are dead: SSL 3.0 falls to POODLE, an attack that reads locked data by forcing errors. TLS 1.0 came in 1999 and TLS 1.1 in 2006, and both are dead too: BEAST and other attacks broke their record locking, and browsers refuse them. TLS 1.2 came in 2008 and is still fine. TLS 1.3 came in 2018 and is the best today: one round trip, old ciphers removed, and the key exchange folded into the hello.
Types:
Uses: I use this when I read a server config or a handshake. I ask which versions the server offers, and I turn off everything below 1.2. Try it now: run the s_client command from step 4 twice, once plain and once with -tls1_2, and compare the Protocol and Cipher lines. Then practice version checks in the TLS labs.
Dimensions: As traffic grows, the version is the tax on every new connection. What breaks is the old device that only speaks TLS 1.0. It costs a hard choice: keep the old device working, or keep the lock strong. The strong lock wins, and the old device gets an update or a replacement.
Definition: A cipher suite names the three tools in the lock: the key exchange, the bulk cipher, and the hash. TLS_AES_256_GCM_SHA384 means AES 256 in GCM mode for the data, SHA-384 for the stamps, and a key exchange agreed in the hello. ECDHE means the key exchange uses elliptic curves and a fresh key every time, which is what gives forward secrecy: a stolen private key cannot unlock old traffic, because the secret was never made from the private key. The curve name in the Server Temp Key line, X25519, is the tool that did it.
Types:
Uses: I use this when I read the Cipher line and the Server Temp Key line of a handshake. I want a suite with ECDHE and a modern bulk cipher, and I want the temp key line to name a strong curve. Try it now: run s_client against the live site and read the Ciphersuite line and the Server Temp Key line. Then practice reading ciphers in the TLS labs.
Dimensions: At ten times the connections, the handshake is the cost you feel, because every new connection pays it before a byte moves. What breaks is a cipher list that still offers a weak suite to old clients. It costs a short list: TLS 1.2 and 1.3 only, ECDHE only, and no suite a scanner flags.
Definition: At this level the handshake stops being one browser and one server. The lock ends at the edge, where the public certificate lives, and the traffic inside the cluster travels on its own lock or a private network. Connections are kept alive so the handshake is paid once for many requests. Sessions resume so a returning visitor skips most of the handshake. And the version policy is enforced and checked in the logs, not just written in the config: I watch for old versions in the handshake logs, because a client that only speaks old TLS is a client I need to find and fix.
Types:
Uses: I use this when more than one service sits behind the edge, or when a slow handshake is the complaint in the metrics. It is also how I review a setup I did not build: I ask where TLS ends, which versions are offered, and what happens when a client only speaks an old one. Try it now: time the same site twice with the curl command, once fresh and once with a reused session, and compare the tls lines.
Dimensions: At a hundred times the traffic, the handshake is not the bottleneck, the blast radius is. What breaks is the edge that terminates TLS for everything, or the certificate that expires on the one server nobody watches. It costs monitoring on the expiry date and a rehearsed renewal, which is Lesson 149.
The version story in one table, from the history. Do this: run echo | openssl s_client -connect mohankrishnapodile.com:443 -servername mohankrishnapodile.com -tls1_3 2>/dev/null | grep -E 'Protocol|Cipher'. Expected output: Protocol : TLSv1.3 and Cipher : TLS_AES_256_GCM_SHA384. Then replace -tls1_3 with -tls1_2. Expected output: Protocol : TLSv1.2 and Cipher : ECDHE-ECDSA-AES256-GCM-SHA384. The same server answers both, and the version you ask for is the version you get.
openssl s_client, flag by flag. This is the command that opens a TLS connection and shows me what the server sends. I run it before I blame the app.
s_client opens a TLS connection and prints what the server sends. It is a client I can watch. I use it to see the certificate and the protocol before I blame the app.-connect host:443 names where to connect, host and port together. Without it s_client has nowhere to go.-servername sends the SNI name, the hostname the server should answer for. Without it a server that hosts many names answers with its default certificate, which may not be the one I asked about.-tls1_1 forces TLS 1.1. A server that only speaks 1.3 answers with no certificate at all. That empty answer is the finding: the old version is gone from the server, and a client that only speaks it cannot connect.-tls1_3 forces TLS 1.3. It proves the server speaks the current version. I run it next to the 1.1 check, so the two answers sit side by side: one empty, one full.echo | pipes an empty line into s_client so it closes the connection after the handshake. Without it s_client waits for my input, and the command never ends.Flags you will meet next: -CAfile names a private CA to trust, -brief prints a short summary, and -showcerts prints the whole chain.
Try it: run the -tls1_3 line, then the -tls1_1 line, against the same server. The 1.3 line prints a protocol and a cipher. The 1.1 line prints no peer certificate available. The two answers side by side are the finding.
SSL 3.0 (1996) dead. POODLE reads locked data. Browsers refuse it.
TLS 1.0 (1999) dead. BEAST and friends broke its records. Browsers refuse it.
TLS 1.1 (2006) dead. Same record problems. Browsers refuse it.
TLS 1.2 (2008) alive. Two round trips. Still the common case.
TLS 1.3 (2018) best today. One round trip. Weak ciphers removed.
What the table means: the version is a negotiation, not a setting you control alone. The browser offers its best, the server picks the best both speak, and the answer is the lower of the two. A server that only speaks TLS 1.0 gets a refusal, not a fallback, because falling back to a broken version is how downgrade attacks work.
Try the refusal yourself. Do this: run echo | openssl s_client -connect mohankrishnapodile.com:443 -servername mohankrishnapodile.com -tls1_1 2>/dev/null. Expected output: an error line that says no protocols available, from your own OpenSSL, before it even talks to the server. OpenSSL 3.0 will not even offer TLS 1.0 or 1.1. That is the version policy enforced at the library level, and it is why a server stuck on 1.0 is unreachable from a modern machine.
One round trip against two, measured. Do this: run the curl timing command from the Try it box twice, once against the live site and once against a far site you use. Expected output: the tls line grows with distance, because the handshake is round trips and round trips are distance. TLS 1.3 pays one round trip for the handshake. TLS 1.2 pays two. On a 150 ms round trip that is 150 ms against 300 ms, before the first byte.
Session resumption is the saving the simulator models. Do this: run curl -s -o /dev/null -w "tls: %{time_appconnect}s\n" https://mohankrishnapodile.com/ twice in a row. Expected output: the second run is usually faster, because curl reuses the connection only within one run, so the saving across runs is small. The real saving is inside one page load: the browser opens several connections, and a resumed session skips the key exchange on each one after the first. Practice the reuse math in the TLS labs.
curl -w, flag by flag. The -w line is a stopwatch, not a download. I use it when I need a number, not a page.
-s hides the progress meter. Without it every run prints progress noise, and the real output gets buried in it.-o /dev/null writes the response body to a file instead of stdout. /dev/null throws it away. I use it when only the status line matters, not the page.-w prints one line I design, using variables like %{http_code}. Without it curl prints the body and nothing else, and I have to guess the status from the page.%{time_total} the whole request time in seconds, from the first byte out to the last byte in. I compare this number between the edge and the origin. The gap is the edge doing its job.%{time_appconnect} the time until the TLS handshake finished. It is the TLS part of the total. On plain http it is zero, because there is no handshake.Flags you will meet next: %{time_connect} stops at the TCP connect, and %{time_starttransfer} stops at the first byte back.
Try it: run the line three times against the same URL and watch the number move. The first run is usually slower. The next two are the real shape.
At 10x the traffic, the shape holds and the numbers grow. At 100x, the design changes: the lock ends at the edge, connections are kept alive, sessions resume, and the version policy is watched in the logs. The handshake never stops being a hello, a certificate, keys, and records. It just gets more readers. Lesson 148 is where the certificate comes from, and Lesson 149 is where it gets checked.
A public site kept TLS 1.0 turned on for one old device that still used it. A scanner flagged the site, and a routine audit failed the whole service over one old version. The site was not breached. It was just one checkbox in a config, left on for a device nobody could name. The audit failed anyway, because the version list is a security decision and the list said 1.0 was welcome.
Two things. First, the version list is now TLS 1.2 and 1.3 only, and it is checked by a scan on a schedule, not by memory. Second, a version is never kept for a device nobody can name. Try it now: pick any site you run and run s_client against it with -tls1_1. If it answers instead of refusing, the old versions are still on.
Read three real handshakes and write down what each one agreed: the version, the cipher, and the temp key. One against the live site with TLS 1.3, one against the same site forced to TLS 1.2, and one refusal against the same site with TLS 1.1. It passes when you can say, for each of the three, the version that was agreed or the exact error that refused it.
Success looks like this: three handshakes written down, two agreed with a version, a cipher, and a temp key each, and one refused with the no protocols available error. The curl timing shows a tls line and a total line, and you can say which one is bigger and why.
If s_client prints nothing, check the server name flag: without -servername the server may answer with a default certificate or refuse. If curl shows a tls line of zero, the connection was reused from a warm cache in the same run, so run it once more in a fresh shell. If the -tls1_1 run seems to connect, read the whole output: the Verify return code line prints even when the handshake failed, and the error line above it is the truth.