Capture Filter

You cannot directly filter TLS protocols while capturing. However, if you know the TCP port used (see above), you can filter on that one, for example using tcp port 443.

Using the (Pre)-Master-Secret

The master secret enables TLS decryption in Wireshark and can be supplied via the Key Log File. The pre-master secret is the result from the key exchange and can be converted to a master secret by Wireshark. This pre-master secret can be obtained when a RSA private key is provided and a RSA key exchange is in use.

Step-by-step instructions to decrypt TLS traffic from Chrome or Firefox in Wireshark:

  1. Close the browser completely (check your task manager just to be sure). 确定所有浏览器已关闭,任务管理器中查看。
  2. Set environment variable SSLKEYLOGFILE to the absolute path of a writable file.
  3. Start the browser.
  4. Verify that the location from step 2 is created.
  5. In Wireshark, go to Edit -> Preferences -> Protocols -> TLS, and change the (Pre)-Master-Secret log filename preference to the path from step 2.
  6. Start the Wireshark capture.
  7. Open a website, for example
  8. Check that the decrypted data is visible. For example, using the tls and (http or http2) filter.

For Windows, an environment variable can be set globally as described in this walkthrough, but this is not recommended since it is easy to forget about and may be a security issue since it allows decryption of all your TLS traffic. A better way to set the environment variable is via a batch file. Create a file start-fx.cmd with:

@echo off
set SSLKEYLOGFILE=%USERPROFILE%\Desktop\keylogfile.txt
start firefox

For Linux, you open a terminal then start the browser with:

export SSLKEYLOGFILE=$HOME/Desktop/keylogfile.txt

For macos, you open a terminal then start the browser with:

export SSLKEYLOGFILE=$HOME/Desktop/keylogfile.txt
open -a firefox

Change the SSLKEYLOGFILE path as needed, and replace firefox with chrome for Google Chrome. This mechanism currently (2019) does not work for Safari, Microsoft Edge, and others since their TLS libraries (Microsoft SChannel/Apple SecureTransport) do not support this mechanism. This mechanism works for applications other than web browsers as well, but it dependent on the TLS library used by the application.

Note: Chromium based versions of Edge (version 79+) should work too.

Examples of other applications:

For a survey of supported TLS applications and libraries, see also page 19 of Peter Wu’s SSL/TLS Decryption SharkFest’18 EU presentation.

Embedding decryption secrets in a pcapng file

Since Wireshark 3.0 you can embed the TLS key log file in a pcapng file. This makes it much easier to distribute capture files with decryption secrets, and makes switching between capture files easier since the TLS protocol preference does not have to be updated. To add the contents of key log file keys.txt to capture file in.pcap and write the result to out-dsb.pcapng:

editcap --inject-secrets tls,keys.txt in.pcap out-dsb.pcapng

The dsb suffix stands for Decryption Secrets Block (DSB) and is part of the pcapng specification.

A key log file might contain keys that are not related to a capture file. To ensure that unnecessary keys are not leaked, you can use the script from to filter the key log file and add the required secrets to a capture file. The shell script has been tested with Linux and macOS, but a Python 3 version is also available for all platforms including Windows. Example:

git clone ~/its
~/its/ keys.txt some.pcap

See also

Some other protocols are derived from TLS. This includes:

External links



邮箱地址不会被公开。 必填项已用*标注