UPDATE:I’m in the process of migrating my most popular articles and writing some new posts over at redflagsecurity.net. See the latest version of this post at this link.

Intro

Most IT people are somewhat familiar with Wireshark. It is a traffic analyzer, that helps you learn how networking works, diagnose problems and much more.

One of the problems with the way Wireshark works is that it can’t easily analyze encrypted traffic, like TLS. It used to be if you had the private key(s) you could feed them into Wireshark and it would decrypt the traffic on the fly, but it only worked when using RSA for the key exchange mechanism. As people have started to embrace forward secrecy this broke, as having the private key is no longer enough derive the actual session key used to decrypt the data. The other problem with this is that a private key should not or can not leave the client, server, or HSM it is in. This lead me to coming up with very contrived ways of man-in-the-middling myself to decrypt the traffic(e.g. sslstrip or mitmproxy).

Session Key Logging to the Rescue!

Well my friends I’m here to tell you that there is an easier way! It turns out that Firefox and Chrome both support logging the symmetric session key used to encrypt TLS traffic to a file. You can then point Wireshark at said file and presto! decrypted TLS traffic. Read on to learn how to set this up.

Setting up our Browsers

We need to set an environmental variable.

On Windows:

Go into your computer properties, then click “Advance system settings” then “Environment Variables…”

Add a new user variable called “SSLKEYLOGFILE” and point it at the location that you want the log file to be located at.

On Linux or Mac OS X: