5 min read

How to Decrypt HTTPS Traffic: TLS Decryption with keylog (HTTP/2 & QUIC)

Captured HTTPS is ciphertext by default — decrypting it is the hardest step in any HTTPS traffic analysis. With the client's SSLKEYLOGFILE the whole session becomes readable. This guide covers where keylogs come from, how to import them, how far recovery goes, and how TLS 1.3, HTTP/2 and QUIC each differ.

How to Decrypt HTTPS Traffic: TLS Decryption with keylog (HTTP/2 & QUIC)
SummaryKey Points
  • A keylog holds ephemeral keys exported during negotiation and is only valid for that session
  • pcapng can embed keys in a Decryption Secrets Block, making one file self-contained
  • TLS 1.3 decryption recovers application data only; post-handshake certificates stay hidden
  • QUIC decryption currently covers Initial packets, enough for ClientHello and metadata

What a keylog Is and Where It Comes From

TLS 1.2 session keys can be derived from the server's private key, so having the key is enough to decrypt (provided the client did not use a forward-secret suite). TLS 1.3 eliminated that path entirely — all mainstream suites are ECDHE, and the private key is useless after key agreement.

The only decryption path in the TLS 1.3 era is a keylog: the client (or server) writes the ephemeral keys it generated into a local file, one line per entry in the form CLIENT_RANDOM . With that file, anyone can recover the plaintext of the corresponding session.

Mainstream clients support this through the SSLKEYLOGFILE environment variable:

export SSLKEYLOGFILE=/tmp/keys.log

Chrome, Firefox, curl, Node.js and Python's ssl module all honor it. Wireshark has an equivalent import preference built on the same mechanism.

An essential constraint: a keylog only matters during the session. It records the ephemeral keys of one handshake; once the session ends and keys rotate, it cannot decrypt new connections. So the correct collection posture is to export the keylog while capturing, with overlapping time windows.

Two Ways to Import

Option 1: Separate file

The capture is a classic pcap and the keylog is a separate .txt / .log / .keys file. Select the keylog in PcapDecoder's TLS decryption card; the engine parses each CLIENT_RANDOM line, matches it against ClientHello randoms in the capture, and attempts decryption on matches.

This suits analyzing someone else's capture — as long as you also receive the keylog, import the two files separately.

Option 2: pcapng with an embedded DSB

The pcapng format defines a Decryption Secrets Block (DSB) that can carry keys inside the capture file. Wireshark's editcap --inject-secrets does this.

Embedding has an obvious advantage: one file carries everything, so "we have the capture but cannot find the keylog" never happens. PcapDecoder reads key blocks from the DSB first and requires no separate import.

For forensic delivery this is the better option — the evidence package is self-contained and the recipient needs nothing else from you.

How Far Recovery Goes

This is the most misunderstood part, so it is worth separating into three layers:

Layer 1: TLS record layer. Successful decryption means the plaintext application data inside TLS records is visible. PcapDecoder reports "N records decrypted / M failed"; failures are typically sessions whose randoms did not match (incomplete keylog or non-overlapping windows).

Layer 2: Application protocol recovery. Decrypted bytes still need protocol parsing:

  • HTTP/1.1: request line, headers and body directly;
  • HTTP/2: requires HPACK header decompression plus stream multiplexing reassembly — PcapDecoder implements this and recovers method / path / host / status per stream;
  • gRPC: sits atop HTTP/2, so methods and statuses are available;
  • QUIC / HTTP/3: see the next section.

This layer is where the analytical value lives — bytes without protocol structure are just noise.

Layer 3: Object recovery. Extract files from HTTP responses (images, documents, executables), determine the real type by magic number, handle gzip. PcapDecoder's forensic extraction does this layer.

How QUIC Differs

QUIC is special. It runs over UDP with its own encryption (a TLS 1.3 handshake, but with the record layer replaced) and maintains three key sets: Initial, Handshake and 1-RTT.

The current implementation decrypts QUIC v1 Initial packets: HKDF derivation per RFC 9001, AES-128-GCM, header protection mask removal, CRYPTO frame reassembly, then reuse of the ClientHello parser. That is enough to recover SNI, ALPN, supported versions and JA3/JA4 fingerprints — in other words, what service the client is requesting.

Initial packets do not carry application data. Reading actual HTTP/3 request content requires 1-RTT keys, i.e. the corresponding QUIC entries in a TLS keylog. That path is not yet wired up, so content analysis over QUIC remains at the metadata level.

State this boundary clearly, so nobody assumes "supports QUIC decryption" means HTTP/3 bodies are visible.

The Workflow

Step 1: Prepare the environment. Set SSLKEYLOGFILE on the client you want to analyze, then start capturing. Order matters — export before capture, otherwise early session keys may never be written.

Step 2: Import the keylog. Open the capture, find the TLS decryption card on the stats page (a PRO feature) and select the keylog file. Any extension is accepted since keylog files have no standard suffix.

Step 3: Read the match results. The card shows keylog entry count, matched stream count, and successful/failed record counts. If matched streams is 0, check whether the windows overlap — the most common cause is that the capture and keylog cover different periods.

Step 4: Inspect the recovered request table. Decrypted streams appear as a table of method, path, host and status. Filter by host or path to hunt for suspicious requests.

Step 5: Export evidence. Decrypted sessions can be exported with the report and a packet index. Before sharing, remember that cleartext may include credentials and tokens — necessary for forensics, but share with care.

Three Limits to State Up Front

  1. It only works on sessions you have keys for. A keylog is exported by the client itself; no third party can forge one. This is key-holding decryption, not breaking;
  2. Forward secrecy exists precisely for this. If a keylog leaks, the corresponding sessions lose confidentiality — so treat keylog files as highly sensitive and clean up after collection;
  3. TLS 1.3 certificates are encrypted. The server certificate travels inside encrypted records after the handshake and is invisible. Certificate health checks must rely on other means (server-side export, or older-version traffic where the Certificate message precedes encryption).

One last point easily overlooked: however strong the decryption, it only applies to sessions you hold keys for. For unfamiliar traffic, what remains is metadata analysis — JA3/JA4 fingerprints, SNI, certificate characteristics, traffic shape. That is exactly why detection cannot depend on decryption alone.


Related reading: TLS 1.3 Handshake Analysis, QUIC Traffic Analysis.

TLSTLS 1.3SSLKEYLOGFILEHTTP/2QUICDecryption
Share
Back to home