Decrypting TLS1.2 Tunnels using Wireshark

This post is about decrypting TLS1.2 tunnels in wireshark.

To decrypt the TLS1.2 tunnels, we need master key that got generated during TLS handshake.

We will take the example of a radsec tunnel (TLS1.2) here. The decryption process will be same for all the implementations where ever TLS1.2 tunnels are used (ex : HTTPS TLS1.2 Tunnels, Radsec Tunnels etc..)

Decrypt Radsec TLS1.2 Tunnels using Wireshark

The below Figure shows the handshake that happens in TLS1.2 Authentication. It is not possible to decrypt the data that is being sent in a TLS tunnels without the master secret. Here in this post we will decrypt the TLS1.2 tunnels by finding out the master secret.

Figure 1 : TLS1.2 HandShake

The below Figure 2 ,sniffer capture shows the TLS1.2 handshake(Here I have captured only the required Frames)

Figure 2 : TLS1.2 Sniffer Capture

Find TLS1.2 48-Byte Master Secret

If we want to decrypt the TLS1.2 Tunnel with Wireshark, we need to find out the master secret. Without this master secret, we will not be able to decrypt the data.

The Master Secret will be stored in the Openssl Session and it is 48 Bytes.

Master Secret is 48 Bytes in TLS1.2 Session and it is stored in the openssl Session, we need to extract that master secret from openssl.

The below code is used to extract the 48 Byte Master Secret from TLS1.2 Session.

      debug(DBG_DBG," key %.2X",ssl->session->master_key[i]);

We will be able to print the master secret on the console output with the code that we have used above.

The output of the above code will look the below. We are displaying 48 bytes (Each byte in a single line)

Figure 3 : 48-Bit Master Secret

Decrypt the TLS1.2 Data Through Wireshark

We need to send the below input to the wireshark to decrypt the data.

  1. Client Random (we will get this from Client Hello)
  2. 48 Byte Master Secret (we got this from the above code snippet)

We have all the information that is required to decrypt the data. We will decrypt the data now using the wireshark.

I have taken one plain UDP radius packet as a reference here and we will compare the results after decrypting the data.

Figure 4 below shows the RADIUS data that is being sent in a TLS1.2 tunnel. I am sending the data in RADSEC1.2 tunnel.

Figure 4 : Radius Access Request in a TLS1.2 Tunnel

Now if we have to decrypt the data using wireshark, we have to store the client random, server random and master secret in a file and access that file from wireshark.

Figure 5 shows, how to do this.

Figure 5 : Wireshark path to read key.log file

Now the key.log file will have the following contents.


CLIENT_RANDOM 48e8e295a22d810d36b72d42cc8f40732e547d89b780f4e40be8aa6da8d645c9 F293AB3590B9AA3AF172594288FEF14F44467F4D6E32D2D30473A6F524C8BF0214A47D3A08559F3B6D26080F5E48363C

After the input is given, we load the wireshark again. Now we will be able to see the decrypted data on the wireshark now.

Now again observe the frame no 18 on wireshark, it has decrypted the traffic on wireshark.

Figure 6 : Decrypted Radsec TLS1.2 Access Request Message on Wireshark

This is how we decrypt the TLS1.2 data through wireshark. Here we took the example for Radsec TLS1.2 tunnel. But the procedure will be same for any TLS1.2 Tunnels.

In the next posts we will learn about Decrypting TLS1.3 tunnels with wireshark.