Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:SSLKEYLOGFILE

From ReverseEngineering.wiki
Format
Extensions none defined; media type application/sslkeylogfile
Website https://www.rfc-editor.org/rfc/rfc9850
On this wiki Facts · Code · Notes · Topics

The text format (RFC 9850) in which TLS clients and servers log session secrets, one 'LABEL client_random secret' line each, so a tool such as Wireshark can decrypt a capture of your own traffic.

Overview

Many TLS libraries can append the secrets of each handshake to a text file, often chosen by an environment variable named SSLKEYLOGFILE. Read in source: NSS reads it itself (sslsock.c calls PR_GetEnvSecure("SSLKEYLOGFILE") and appends to that file, but only when built with NSS_ALLOW_SSLKEYLOGFILE; ssl3con.c writes the lines); curl reads it in lib/vtls/keylog.c (getenv, append mode). OpenSSL does not read the variable: SSL_CTX_set_keylog_callback only hands the application a line "in the format used by NSS for its SSLKEYLOGFILE debugging output", and the application must write the file; Go's crypto/tls likewise has only a Config.KeyLogWriter. Other libraries and applications were not read. Wireshark and similar tools read that file to decrypt a capture of your own traffic. RFC 9850 (July 2026, Informational, "The SSLKEYLOGFILE Format for TLS", read) standardises it. Use it only for your own traffic and test builds; the RFC says it MUST NOT be used in production.

Line format

UTF-8 text without a byte order mark. Lines end in CRLF, CR or LF (readers accept all). Empty lines and lines starting with # are ignored. Every other line is LABEL<space>client_random<space>secret: client_random is the 32-byte Random of the ClientHello as 64 hex characters, the secret is hex whose length depends on the secret. Hex digits may be upper or lower case. The log does not record the cipher suite, so keep the handshake in the capture.

Labels

Label Meaning
CLIENT_RANDOM TLS 1.2 and earlier master secret
CLIENT_EARLY_TRAFFIC_SECRET TLS 1.3 early-data records
EARLY_EXPORTER_SECRET TLS 1.3 early exporter
CLIENT_HANDSHAKE_TRAFFIC_SECRET client handshake records
SERVER_HANDSHAKE_TRAFFIC_SECRET server handshake records
CLIENT_TRAFFIC_SECRET_0 client application records after the handshake
SERVER_TRAFFIC_SECRET_0 server application records after the handshake
EXPORTER_SECRET TLS exporter
ECH_SECRET HPKE shared secret of Encrypted Client Hello
ECH_CONFIG the ECHConfig used

With ECH, the TLS 1.3 labels use the Random of the inner ClientHello when ECH was negotiated, while ECH_SECRET and ECH_CONFIG use the outer one.

In pcapng

A key log can travel inside a capture as a Decryption Secrets Block with Secrets Type 0x544c534b, see Format:Pcapng#Decryption Secrets Block (DSB), 0x0000000A.

Code & repositories

  • https://github.com/the-tcpdump-group/libpcap @ ba925f7be2ad4cc90ff00ea249310679094221a5 · license: BSD-3-Clause (declared by the contributor for the files used; GitHub reports BSD-2-Clause (read from LICENSE; GitHub's detector did not classify it) for the repository)
    libpcap: pcap/sll.h SLL and SLL2 header structs, pcap-linux.c 'any' device link types.
    Tested on: source read, not run: source read, not run: read sll.h and pcap-linux.c · checked 2026-10-18; last activity 2026-10-17

Pitfalls

  • A log without the capture of the handshake (the ClientHello Random) is useless; a capture started mid-connection cannot be decrypted.
  • TLS 1.2 needs one line per connection; TLS 1.3 needs the traffic-secret lines.
  • RFC 9850 says the format can also be used with DTLS, QUIC (RFC 9000, RFC 9001) and other protocols that use the TLS key schedule, so QUIC logs use the same TLS 1.3 labels.

See also Technique:TLS client fingerprinting, Technique:Reversing network protocols.