How can i decrypt Diffie-hellman TCP packets?

I'm trying to make a tool that shows cleartext response from a server that uses this encryption. However when i look online people all seem to say it's impossible to decrypt DHE, which is not true since we are the client and have access to this information,

but how can i decrypt these packets with the handshake in wireshark?

Bonus question: Any tools in python or something that establish DHE connections and show cleartext response?

enter image description here


1 Answer 1


The traffic itself does not contain enough information to decrypt it (if it did, a malicious WiFi hotspot could decrypt TLS making TLS worthless). You need the ephemeral (single-use) private key for the DHE or ECDHE (has nothing to do with a certificate), either the client's or the server's. Alternatively, you need the resulting shared secret. Either the client or the server can write it to log, but only as long as they have it - after the connection is closed, it is gone. There is a standard for such logging for browsers (to produce logs) and for wireshark (to consume logs), called SSLKEYLOGFILE.

See Mozilla docs for NSS Key Log Format and a blog post with screenshots for using it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.