How you do you decrypt ssl packets (traffic) with the private key? I tried to do this with ssldump and openssl but nothing worked.

3 Answers 3


Ssldump is supposed to be able to do that, but it appears to be unmaintained (in the source archive of the latest version, the date of last modification of all files are in 2002 or before) so it is quite possible that it won't support newer SSL/TLS; actually, it is highly implausible that a software from 2002 could process the new encryption formats defined in TLS 1.2 (AES/GCM). TLS 1.1 was published in 2006, and TLS 1.2 in 2008.

OpenSSL is a library that implements the protocol, but is not meant for analysing a recorded session.

You may have better chance with Wireshark, which has ample documentation on how to use it to decrypt recorded sessions.

There is an important parameter to mind: decryption of a passively recorded session (with a copy of the server private key) works only if the key exchange was of type RSA or static DH; with "DHE" and "ECDHE" cipher suites, you won't be able to decrypt such a session, even with knowledge of the server private key. In that case, you will need either the negotiated "master secret", or to use the server private key to actively intercept the connection (in a Man-in-the-Middle setup).


If you have access to the client side making the connections and the browser is Firefox (or, I believe, based on NSS), you can dump ephemeral keys established for any site. To do this run:

$ export SSLKEYLOGFILE=/path/to/logfile.log
$ firefox

You will find logfile.log contains a series of lines along the lines of CLIENT_RANDOM <hex> - you can find these documented here.

In wireshark, you can then go to Edit | Preferences | Protocols | SSL and set the "pre-master-secret logfile name" to the file you set above.

All connections through your firefox browsing session will then be decrypted and visible, regardless of host.

As a caveat, you might not necessarily see easy-to-understand http any longer; I just tried this against google.com and I'm now apparently using http/2.

I am assuming here that you have an ssl-enabled service and your own private key for this and would like to view the session unencrypted - a really useful example of this is to view http/2 in practice, since it is rarely deployed without tls (most browsers won't use it over http) and are wondering why you can't, on a modern setup. The problem, as Tom says, is that you need the ephemeral keys.


You can try the following command with tshark (terminal based wireshark) to decrypt a live session:

tshark -o "ssl.desegment_ssl_records: TRUE" -o "ssl.desegment_ssl_application_data: TRUE" -o "ssl.keys_list:,443,http,./private_key.pem" -o "ssl.debug_file:rsa_private.log" -R "(tcp.port eq 443)" port 443

Note that this will not decrypt application data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .