What is TLS?
TLS wraps a normal connection in encryption. It checks that you are talking to the real server (with a certificate), agrees on fresh keys, and then encrypts and checks every byte, so nobody on the path can read or change it.
TLS is the S in HTTPS, and it also protects mail (IMAPS, SMTP with STARTTLS), DNS over HTTPS and many app connections. TLS 1.3, the current version, needs only one round trip to set up and removed every old, weak option.
Think of it like this. TLS is like meeting a courier at a bank. First you check the courier's photo ID against a list you trust (the certificate). Then you both agree on a lock combination using a trick that works even if someone overhears you (the key exchange). From then on every parcel travels in a locked, tamper-proof box.
Step by step
Normal
6 stepsA full TLS 1.3 handshake to an HTTPS site, then the first encrypted request.
Normal
6 stepsA full TLS 1.3 handshake to an HTTPS site, then the first encrypted request.
- 1
TCP connection
Three packets open port 443
TLS runs on top of TCP, so the usual SYN, SYN-ACK and ACK come first. Nothing is secret yet.
- 2
Client Hello
Here is what I support, and my key share
The laptop sends its random value, the cipher suites it supports, the site name (SNI) and its half of an X25519 key exchange. Everything in this message is readable by onlookers.
- 3
Server Hello
The server picks and sends its key share
The server chooses TLS 1.3 and a cipher suite, and sends its own key share. Both sides can now compute the same secret without ever sending it. From here on, the server encrypts.
- 4
Server proves itself
Certificate, signature and Finished
Inside encryption, the server sends its certificate chain, a signature over the whole handshake made with its private key (CertificateVerify) and a Finished check. The laptop checks the name, the dates and that a trusted authority signed the certificate.
- 5
Client Finished
The laptop confirms the handshake
The laptop sends its own Finished message. It proves both sides saw the same handshake, so nobody tampered with it on the way. One round trip after Client Hello, the laptop may send data.
- 6
Encrypted traffic
HTTP requests inside TLS
Requests and responses now travel as encrypted records. The server also sends session tickets so the next visit can be faster.
0-RTT resume
4 stepsComing back later with a session ticket: no certificate, and a request sent in the very first flight.
0-RTT resume
4 stepsComing back later with a session ticket: no certificate, and a request sent in the very first flight.
- 1
TCP connection
Same three packets as before
TLS resumption saves round trips inside TLS, not TCP. The TCP handshake still happens.
- 2
Hello with a ticket
Pre-shared key plus early data
The laptop sends the ticket from last time in the pre_shared_key extension, a fresh key share, and says it has early data. Right behind it, a GET request encrypted with a key made from the ticket. This is 0-RTT data.
- 3
Server accepts
No certificate needed
The ticket proves this is the same server as before, so there is no certificate or signature. A fresh X25519 exchange still gives forward secrecy for the rest of the session.
- 4
Done
Response, then the client Finished
The server can answer the early request at once. 0-RTT data can be replayed by an attacker who records it, so servers only accept safe requests like GET there, and may refuse early data entirely.
Expired certificate
3 stepsThe server's certificate has expired, so the browser stops before sending anything private.
Expired certificate
3 stepsThe server's certificate has expired, so the browser stops before sending anything private.
- 1
Hellos as usual
Client Hello and Server Hello
The handshake starts normally. Key exchange does not depend on the certificate yet.
- 2
Certificate check fails
Valid until 1 November 2026
The laptop reads the certificate's dates and finds it expired. The same check also catches a name that does not match (a certificate for another site) and an issuer the laptop does not trust.
- 3
Alert and close
certificate_expired, then FIN
The laptop sends a fatal alert and closes the connection. No cookie, password or request was ever sent. The browser shows a full-page warning instead of the site.
Myths and mix-ups
- The padlock does not mean a site is honest; it means your connection to that exact name is private.
- TLS does not hide which site you visit: the server name (SNI) and the IP address are still visible.
- SSL is not what you use today; SSL is the retired ancestor, and the name stuck.
- Encryption is not slow anymore: TLS 1.3 adds one round trip, and resumption can remove it.
- A certificate is not secret; the private key that matches it is.
Try it yourself
Run these on your own computer to see TLS at work.
Watch a handshake
openssl s_client -connect example.com:443 -servername example.comShows the certificate chain, the TLS version and the cipher. Press Ctrl+C to quit.
Short summary
openssl s_client -connect example.com:443 -servername example.com -briefOne line each for the version, cipher and peer certificate.
Certificate dates
echo | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -subject -datesPrints who the certificate is for and when it expires.
From curl
curl -v https://example.com/ -o /dev/nullLines starting with * show the TLS handshake steps and the certificate checks.
TLS at a glance
- Layer
- Between transport and application (often called 6)
- Port
- None of its own: HTTPS 443, IMAPS 993, SMTPS 465
- Transport
- TCP (QUIC builds TLS 1.3 in)
- Current version
- TLS 1.3 (2018), TLS 1.2 still common
- Handshake
- 1 round trip in TLS 1.3, 2 in TLS 1.2
- Key exchange
- Ephemeral ECDHE, usually X25519
- Ciphers
- AES-GCM or ChaCha20-Poly1305
- Retired
- SSL 2.0, SSL 3.0, TLS 1.0 and 1.1
Defined inRFC 8446 (TLS 1.3)RFC 5246 (TLS 1.2)RFC 6066 (SNI)RFC 7301 (ALPN)RFC 8996 (retires TLS 1.0 and 1.1)
Header fields
What TLS puts in its messages, with example values from the stories above.
TLS record
- Content type
23 (Application Data)In TLS 1.3 almost everything after the hellos is labelled application data, so an onlooker cannot even tell which message it is.- Legacy version
0x0303 (shows TLS 1.2)Kept at the old value so old middleboxes do not choke. The real version is agreed in an extension.- Length
512- Handshake type
1 (Client Hello)- Random
32 random bytesFresh randomness from each side makes every session's keys different.- Cipher suites
TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256The laptop lists what it can do. The server picks one.- server_name (SNI)
shop.example.comTells the server which site you want, since one IP can host many. It is sent before encryption, so onlookers can see it.- supported_versions
TLS 1.3, TLS 1.2This is where TLS 1.3 is really requested.- key_share
x25519, 32-byte public keyThe laptop guesses the key exchange group and sends its half now. That guess is what saves a full round trip in TLS 1.3.- ALPN
h2, http/1.1Asks which app protocol to speak inside, so HTTP/2 can start right away.
Test yourself
How many round trips does a full TLS 1.3 handshake take before the client can send data?
Questions people ask
What is the difference between SSL and TLS?
TLS is the modern successor of SSL. All SSL versions are broken and retired. People still say SSL certificate, but the connection itself uses TLS 1.2 or 1.3.
What port does TLS use?
None of its own. Each protocol picks one: HTTPS uses 443, IMAPS 993, SMTPS 465 and LDAPS 636. Some protocols upgrade a plain connection to TLS with STARTTLS.
Why does my browser say Your connection is not private?
The certificate check failed: it expired, it was made for another name, or it was not signed by an authority your device trusts. A wrong device clock can also cause it. Do not type passwords on that page.
Is TLS 1.2 still safe?
Yes, when set up with modern ciphers (ECDHE with AES-GCM or ChaCha20-Poly1305). TLS 1.3 is simpler and faster, so new setups should prefer it.
Does TLS protect against quantum computers?
Newer browsers and servers add a post-quantum key exchange (a hybrid of X25519 and ML-KEM) to the Client Hello, so recorded traffic stays safe in the future. Older setups use X25519 alone.