The Messages, in Order
With trace(true) each end keeps OpenSSL's own trace of the handshake. Read the names of the messages and their lengths from the client's trace of a handshake made in this tab, in order, and count what each end saw.
The question
The flights of the first chapter were runs of records. Inside the records are handshake messages, and each end knows which ones it sent and read. If a context has trace(true) it keeps OpenSSL's own trace of what it did. A line such as ClientHello, Length=306 names one handshake message and gives its length.
Which messages does the client see, in what order, and how long are they? The trace has many other lines too: how can a program pick out only the messages?
Work it by hand
RFC 9846 section 2 draws the order in its Figure 1: ClientHello, ServerHello, EncryptedExtensions, Certificate, CertificateVerify, Finished from the server, and Finished from the client. Their definitions are in sections 4.2.2, 4.2.3, 4.4.1, 4.5.1, 4.5.2 and 4.5.3. After it has received the client's Finished the server may also send NewSessionTicket messages (RFC 9846 section 4.7.1).
For the demo below, the client's trace should therefore name the seven messages of the figure, in that order, each once on a line of the form Name, Length=n. The lengths are from this build (lmssl 0.2.2, OpenSSL 4.0.3).
Length= counts the message without its 4-byte handshake header: the Certificate of 1785 is the 1806-byte record of the second lesson, less 4 for the header, 1 for the inner type and 16 for the tag.
Run it
The program switches trace(true) on for the client in line 4, steps the pair in the loop of lines 7 to 9 and then reads the client's trace. The loop of lines 11 to 16 keeps only the lines that contain , Length=, in line 13, and turns each into a row. The rest of the trace holds randoms and key shares, which are different on every run: the page never returns it.

Watch the steps (recorded video)
Public test material, generated for this lesson. Never use it for anything real.
let server = ssl.server_ctx(ssl.parse_cert(leaf_pem), ssl.parse_key(leaf_key));
server.chain(ssl.parse_cert(int_pem)); server.groups("X25519");
let client = ssl.client_ctx(); client.add_ca(ssl.parse_cert(root_pem));
client.groups("X25519"); client.trace(true);
let pair = ssl.tls_pair(client, server, host);
let turns = 0;
while (!pair.done() && pair.error() == "" && turns < 10) {
let flight = pair.step(); turns = turns + 1;
}
let rows = str_list(); let lines = str_split(pair.client_trace(), "\n");
for (i in range(0, lines.len())) {
let line = str_trim(lines.at(i));
if (str_contains(line, ", Length=") && rows.len() < 16) {
rows.add(str_replace(line, ", Length=", "|"));
}
}
lmcode_return_put("rows", rows);
let answer = rows.len();
{
"answer": 7,
"rows": [
"ClientHello|306",
"ServerHello|118",
"EncryptedExtensions|2",
"Certificate|1785",
"CertificateVerify|260",
"Finished|48",
"Finished|48"
]
}The picture is a table of the messages and their lengths, and line 18 returns how many there are. You can change host. A name the certificate does not cover, such as shop.example.test, still runs, but the client refuses the certificate and its trace stops early: the table has 4 rows. A name of one character, such as x, stops line 5 with "Line 5: Ssl.tls_pair: set host to verify". The four PEM texts are test material: leave them as they are.
Your turn
The program below is meant to return how many handshake messages the client's trace names and how many the server's trace names, as a list of two numbers. It asks the server for server_group, which takes X25519 or P-256, and leaves the client's groups at their default. A name that no group matches stops line 10 with "Line 10: TlsCtx.groups: no usable group in 'P-256x'".
Decide whether the program does what it should, and find the candidates that do. Check runs each candidate on the data shown and on six others.

Public test material, generated for this lesson. Never use it for anything real.
fn tally(trace: string) -> int {
let lines = str_split(trace, "\n"); let found = 0;
for (i in range(0, lines.len())) {
let line = str_trim(lines.at(i));
if (str_contains(line, "Length")) { found = found + 1; }
}
return found;
}
let server = ssl.server_ctx(ssl.parse_cert(leaf_pem), ssl.parse_key(leaf_key));
server.chain(ssl.parse_cert(int_pem)); server.groups(server_group);
server.trace(true);
let client = ssl.client_ctx(); client.add_ca(ssl.parse_cert(root_pem));
client.trace(true);
let pair = ssl.tls_pair(client, server, host);
let turns = 0;
while (!pair.done() && pair.error() == "" && turns < 10) {
let flight = pair.step(); turns = turns + 1;
}
let answer = int_list();
answer.add(tally(pair.client_trace())); answer.add(tally(pair.server_trace()));
lmcode_return_put("turns", turns);
{
"answer": [
16,
20
],
"turns": 4
}The program builds a TLS client and a TLS server from the test chain, with the server asking for the group in server_group and the client keeping its default groups, switches trace(true) on at both ends, joins them in memory and steps them. A handshake message appears in an end's trace on a line of the form Name, Length=n. Return, as a list, the number of handshake messages in the client's trace and the number in the server's trace. Check runs your program with other names and other test material.
Read the result carefully
Each end knows only what it sent or read: the two traces are not the same list, and a refused certificate ends the client's earlier than the server's. The traces show decoded messages because this end holds the keys; someone between the ends sees the two hellos in the clear and after them only records of type 23, as in the second lesson. The bytes of each message are in the recording of A TLS 1.3 Handshake, Message by Message.
The two ends are test endpoints in this tab's memory and the certificates are test material. The test chain is valid from 2026-01-01 to 2036-01-01 and the client checks the dates against the reader's clock; outside those years the client refuses the certificate.
Recap
- A trace line of the form
Name, Length=nnames one handshake message. - Several messages share one flight; here each has its own record, and RFC 9846 section 5.1 allows several messages in one record.
- Each end's trace lists what that end sent or read.
- Message lengths are what this build does.