TLS 1.3 gets described as “one round trip,” which is true and also unhelpful. The useful part is that the ServerHello is the last message sent in the clear, and every key after it is derived from a transcript of bytes both sides have already seen.
That design removes a lot of old machinery. RSA key transport, CBC modes, compression, renegotiation, and DSA are gone. What remains is a small set of AEAD ciphers, an ephemeral key exchange, and a hash-based key schedule. The moving parts are fewer than in TLS 1.2, but they are linked more tightly, so it pays to know the order.
Before the handshake: the record layer
TLS is a record protocol carrying a handshake protocol. Every record has a five-byte header:
type(1) legacy_version(2) length(2)
Handshake messages use type 22, alerts 21, application data 23. After the keys are installed, a record’s outer type is almost always 23, even when the plaintext inside is a handshake message. The real content type is appended to the plaintext before encryption and stripped after decryption.
The plaintext that gets sealed is:
content || content_type(1) || zero padding
The trailing zeros are padding, and their count is implicit: everything after the content type that is zero is padding. This is how TLS 1.3 hides the true length of handshake messages without a separate length field inside the ciphertext.
Each record is encrypted with AES-GCM or ChaCha20-Poly1305. The nonce is the static IV XORed with a 64-bit sequence number, and the additional authenticated data is the record header. For AES-GCM the IV is 12 bytes; the sequence number starts at zero in each direction and never repeats. The maximum plaintext per record is 16 KiB.
ClientHello: the only plaintext request
The client starts with a ClientHello that looks, at the field level, a lot like TLS 1.2:
legacy_versionset to 0x0303, because middleboxes get confused otherwise.- 32 random bytes.
- A legacy session ID, often present purely for compatibility.
- A list of cipher suites, now only AEAD suites such as
TLS_AES_128_GCM_SHA256andTLS_CHACHA20_POLY1305_SHA256. - Compression methods, always just
null. - Extensions.
Two extensions carry the version negotiation. supported_versions lists 0x0304 for TLS 1.3. key_share carries one or more ephemeral public keys, usually X25519: 32 bytes each. signature_algorithms tells the server which signature schemes the client can verify. server_name carries SNI in the clear unless Encrypted Client Hello is in use, which is still unevenly deployed.
The client is not yet authenticated, and it has not proved it can complete a key exchange. It has only offered a public key.
If the server does not like the offered group, it can send a HelloRetryRequest, which is a ServerHello with a special random value. The client then sends a second ClientHello with a corrected key share. That is the only case where the handshake takes an extra round trip.
ServerHello and the encrypted flight
The server picks a cipher suite, a key share, and a version. Its ServerHello is still plaintext. Everything after it is not:
ServerHello
{EncryptedExtensions} ALPN, SNI acknowledgement
{CertificateRequest} optional, for client auth
{Certificate} the chain
{CertificateVerify} signature over the transcript
{Finished} HMAC over the transcript
The braces mark what is encrypted. A passive observer sees the server’s certificate length and timing, not its contents. That closes a long-standing leak: in TLS 1.2, anyone on the path could read the certificate and learn which internal hostname or which customer domain was being visited.
The CertificateVerify signature is not over the certificate alone. It covers the handshake transcript:
signature = Sign(server_key,
64 bytes of 0x20
|| "TLS 1.3, server CertificateVerify"
|| 0x00
|| Transcript-Hash(Handshake Context, Certificate))
The 64 spaces and the context string prevent a signature from one protocol being replayed in another. The client verifies it with the public key from the leaf certificate, then verifies the certificate chain separately.
Finished is an HMAC, not a signature. Both sides compute:
finished_key = HKDF-Expand-Label(base_key, "finished", "", Hash.length)
verify_data = HMAC(finished_key, Transcript-Hash(...))
The client’s Finished is encrypted under the client’s handshake traffic key. After that, application data can flow. The server can send application data as soon as it has sent its own Finished; the client can send it after its Finished.
The key schedule
TLS 1.3 derives keys in stages rather than negotiating a single master secret. Each stage mixes in more material and produces traffic secrets for a specific phase.
0 (or PSK)
|
v
HKDF-Extract = Early Secret
|
Derive-Secret(., "derived")
|
(EC)DHE -------> HKDF-Extract = Handshake Secret
|
+---------+----------+
| |
"c hs traffic" "s hs traffic"
| |
client hs keys server hs keys
|
Derive-Secret(., "derived")
|
0 ------> HKDF-Extract = Master Secret
|
+---------+----------+
| |
"c ap traffic" "s ap traffic"
| |
client app keys server app keys
HKDF-Extract(salt, input) is a single HMAC. HKDF-Expand-Label(secret, label, context, length) expands it with the TLS label prefix and the transcript hash where the stage calls for one. A traffic secret becomes an AEAD key and IV through two more expansions:
key = HKDF-Expand-Label(secret, "key", "", key_length)
iv = HKDF-Expand-Label(secret, "iv", "", iv_length)
The transcript hash is the running hash of all handshake messages, in order, with the handshake message headers included. It is what binds the keys to the exact negotiation. Change one byte of the ClientHello and the Finished MAC no longer verifies, because the transcript changed and every derived value changed with it.
This is also why the early secret is weak on its own. Before the (EC)DHE share is mixed in, it is derived only from a PSK or from zeros. The handshake secret is the first one with fresh entropy from both sides. The master secret adds another extraction so that compromise of the handshake keys does not directly yield the application keys.
What the client is supposed to check
The handshake proves the server holds the private key for the leaf certificate. It does not prove that the certificate is the right one for this host. That is the client’s job, and it is where custom TLS code tends to fail.
A correct chain validation does all of this:
- Build a path. Leaf to intermediate to a root in the trust store. Servers normally omit the root; clients must not require it.
- Verify each signature. Each certificate is signed by the next one’s key. The algorithm and parameters must be acceptable, not just mathematically valid.
- Check validity.
notBeforeandnotAfteron every certificate in the path, against a clock you trust. - Match the name. The
subjectAltNameextension,dNSNameentries for hostnames,iPAddressfor IPs. Wildcards match one leftmost label only:*.example.commatchesapi.example.comand does not matchapi.eu.example.comorexample.com. The legacy CN fallback is gone from modern validators. - Check basic constraints. CAs need
CA:TRUE, and anypathLenConstraintmust hold. The leaf must not be a CA. - Check key usage and EKU. The leaf needs
digitalSignature, because TLS 1.3 has no key encipherment. If an EKU is present, it must includeserverAuth, and the chain must not contain an EKU that excludes it. - Check revocation. CRL or OCSP, or a stapled response. Most clients soft-fail when the revocation source is unreachable, which means an attacker who can block the OCSP responder gets the old behavior.
- Apply local policy. Minimum key sizes, allowed curves, name constraints, and for public CAs, Certificate Transparency log inclusion.
Steps 1 through 3 are what most libraries mean by “verify.” Step 4 is separate, and forgetting it is the classic bug: a chain can be entirely valid and still belong to a different hostname. In OpenSSL the check is X509_check_host, and s_client exposes it as -verify_hostname; in Go it is tls.Config.ServerName plus VerifyHostname if you are verifying manually; in Python, ssl.create_default_context() does the right thing only if you pass server_hostname to wrap_socket.
A short Python client that gets all of this from the standard library:
import socket
import ssl
ctx = ssl.create_default_context()
ctx.minimum_version = ssl.TLSVersion.TLSv1_3
with socket.create_connection(("example.com", 443), timeout=10) as raw:
with ctx.wrap_socket(raw, server_hostname="example.com") as tls:
print(tls.version()) # TLSv1.3
print(tls.cipher()) # ('TLS_AES_256_GCM_SHA384', 'TLSv1.3', 256)
for kind, value in tls.getpeercert()["subjectAltName"]:
print(kind, value)
create_default_context() enables verification and, because server_hostname is supplied, the hostname check too. Drop server_hostname and it refuses to wrap the socket; turn off check_hostname as well and the handshake succeeds with no name check at all. That second shape turns up in internal tooling often enough to be worth testing for.
0-RTT and replay
TLS 1.3 allows a client that has a valid session ticket to send application data in its first flight, before the server has replied. The client derives an early secret from the PSK, encrypts the data under early traffic keys, and includes it after the ClientHello.
The performance win is real for repeat connections. The security properties are worse than the rest of the handshake, in two specific ways.
First, early data has no fresh key exchange. It is protected by the PSK alone, so it lacks forward secrecy; if the PSK is later compromised, recorded early data can be decrypted. Second, it is replayable. An attacker who captures the ClientHello and the early data can send them again, and the server has no cryptographic way to tell the copy from the original. TLS stacks implement anti-replay using single-use tickets and a time window, but that state is per-server, and it gets harder in a load-balanced deployment where the ticket may be presented to a different node.
The practical rule: only send idempotent requests in early data, never anything that changes state or money, and configure the server to reject early data it cannot prove is fresh. Most applications are better off disabling 0-RTT entirely until they have a reason.
Inspecting a connection
openssl s_client will show the plaintext flight and then a wall of encrypted records, which is a decent illustration of where the boundary falls:
openssl s_client -connect example.com:443 -servername example.com \
-tls1_3 -state -msg
The -msg output shows the handshake message types and lengths. -state prints the state machine transitions. After ServerHello, the message bodies become opaque because the handshake keys are already installed.
To see inside, capture with Wireshark and set SSLKEYLOGFILE before running the client. Browsers and curl honor it; the file contains the per-connection traffic secrets in NSS key log format. With those, Wireshark decrypts the stream and you can compare the transcript hash it computes against the one in the Finished message.
For certificates specifically:
openssl s_client -connect example.com:443 -servername example.com \
-showcerts </dev/null 2>/dev/null | openssl x509 -noout -text
The output is long, but the fields that matter are near the top: validity, SAN, basic constraints, EKU, and the signature algorithm. If a chain fails on one machine and works on another, compare the trust stores first, then the clocks, then the intermediate certificates the server is sending. A missing intermediate is the most common cause of “it works in the browser and nowhere else,” because browsers cache intermediates and most command-line clients do not.
TLS 1.3 is a good protocol to read at the byte level because it is compact enough to hold in your head. The handshake is one flight each way, the key schedule is a handful of HMACs, and the certificate rules are the same ones that were always there. The fragile part is everything the client decides to trust after the math checks out.