Hi, I am wondering whether the TLSv1 traffic for the webapp I am working on can be decrypted. More precisely I am interested in decrypting the traffic that contains.SSL Decryption with Wireshark (Private key and Pre- Master secret). Troubleshooting communication problems with Wireshark can be difficult at the best of times, yet alone when the connection is encrypted with SSL/TLS. One assumes you have root access to the server you are having problems with and you're able to obtain a copy of the public and private key. If you only have access to the server as a client with no special privileges, there are still a couple of ways to take look at the encrypted data. Before you look at either method, it would be useful to do a little background reading on SSL/TLS as the encryption methods might not work quite as you think. In a nutshell, when a client (in most cases, a web browser) makes a connection to a web server requiring SSL/TLS encryption - the encrypted channel is setup using a symmetric session key. This key is a random string generated by the client and then encrypted and transmitted using the servers public key, known as the Pre- master Secret. Once shared, the client and server use this shared key to encrypt and decrypt traffic. There's a more detailed version of this here, but knowing this you be able to see how you can decrypt the traffic using the SSL session key or the servers private key.
This can be hidden in a variety of locations so you'll have to refer to your server documentation for where to find it. Usually it will be a single file with an extension of . CRT, . PEM, . DER or in some cases . PFX or . P1. 2. The latter two are certificate containers which contain the private key, public key and the certificate of the issuing CA. Once you've found the private key, it will make things easier if they're in PEM format with an unencrypted key. The best way to do the conversion is to use Open. SSL. It can be a bit confusing at first but you'll soon get used to how it works. There is a good selection of commands here (they also offer an upload / convert tool. How Certificates Use Digital Signatures. Update: user rturnbul noticed that I accidentally wrote 'private key' when I meant 'public key' when discussing man-in-the. Not to say they're not trustworthy, but I wouldn't recommend giving your private key to anyone. Ever.)Now you have the private key, you'll need to load this into Wireshark and configure it to use this key for any traffic to or from your web server. Go to Edit > Preferences. Then Protocols > SSL. Next to the RSA keys list text, click the edit button. From here select the servers private key and enter the IP address of the web server that will be present in the capture. Select port 4. 43 (or whichever port your application runs on) and the protocol which is inside the encrypted tunnel. In most cases, this will be HTTP but could be IMAP, SMTP etc. The password field can be left blank if you've saved the key in an unencrypted form, otherwise provide the password here. Click OK until you're back to the Wireshark main screen. Now start the capture and generate some encrypted traffic to your web server. Make sure you are using a totally new session. Clearing the cache then closing and reopening your browser would be ideal. Stop the capture when you've generated a few connections. Back in the main window, you should now find that the SSL wrapping has been removed and you're able to view the protocol details within. By default, this key isn't logged anywhere for obvious reasons but with Chrome it's possible to set an environment variable and have these written to disk.(Windows 7) Right click on 'My Computer' and then go to properties. Then click Advanced System Settings > Environment Variables. Then under system variables - create a new variable named SSLKEYLOGFILE with the value being a text file. In this case I went with C: \premaster. Click OK through all open dialogs. I've found this didn't take effect immediately and needed a reboot before it started logging. Back in Wireshark, head to Edit > Preferences > Protocols > SSL. Under the option for '(Pre)Master- Secret log file name' - select your log file you created above (so C: \premaster. Start your capture in Wireshark and then generate a few SSL connections in Chrome. Stop the capture when you're done. In Wireshark, you should again see that your encrypted traffic is now unwrapped ready for some troubleshooting. If you don't, check the pre- master file you've created exists and has some contents. If not you should double check your environment variable. Fiddler is an excellent local proxy application which can perform SSL termination and re- encryption (otherwise known as 'man- in- the- middle' / MITM). If you don't need a full packet capture and can make do with the HTTP requests and responses this might save you a lot of pain.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2017
Categories |