Capture Java VM Traffic using Fiddler
Customer’s using the Azure SDK for Java may need to capture network traffic for the REST API requests to troubleshoot issues. Below are the steps to configure Fiddler and Eclipse to capture the API requests. Telerik provides documentation for configuring your Java app to send traffic to Fiddler available here, however, additional steps will be need to capture secure traffic which is provided in this article. Other development tools can be used but this article covers Eclipse and IntelliJ IDEA. To use other tools, use the VM arguments described in either the Eclipse or IntelliJ IDEA sections.
Prerequisites
Networking Tracing- Fiddler - https://www.telerik.com/download/fiddler
Development Tools
Eclipse - https://www.eclipse.org/downloads/ or IntelliJ IDEA Community - https://www.jetbrains.com/idea/download/
Configuring Fiddler
By default, Fiddler is not configured to decode any encoded traffic. To enable this feature you can select an encoded request/response and select the “click to decode” message.
TIP: Stop capturing of all traffic from Fiddler by pressing f12. All traffic sent from the Java App will still be captured in Fiddler when traffic is sent using the proxy settings. This makes it easier to troubleshoot the requests coming from the app.
You will also need to perform the following.
- Select the Tools menu.
- Choose Telerik Fiddler Options.
-
Select the HTTPS tab and check the following
a) Capture HTTPS CONNECTs
b) Decrypt HTTPS Traffic
-
We’ll need to export the certificate used by Fiddler to use with Eclipse later. Perform the following.
a) Select the “Actions” button.
b) Choose “Export Root Certificate to Desktop. Press the OK button.
-
To create a keystore with this certificate, perform the following.
a) Open the command line as administrator.
b) echo %JAVA_HOME%
c) Change directories to the variable provided (I.e. C:\Program Files\Java\jdk1.8.0_121 in my case).
d) cd bin
e) keytool.exe -import -file C:\Users\
\\Desktop\\FiddlerRoot.cer -keystore FiddlerKeystore -alias Fiddler f) Enter a password and confirm the password.
g) Trust this certificate? [no]: y
h) Example screenshot below.
Configure Eclipse
-
In Eclipse, select the Run menu and choose “Run Configurations”.
-
Select your Project and choose the “Arguments” tab.
-
Enter the following in the VM arguments section.
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 -Djavax.net.ssl.trustStore="path\to\java_home\bin\FiddlerKeyStore" -Djavax.net.ssl.trustStorePassword="password_used_during_keystore_creation"
Configuring IntelliJ IDEA
-
Select the Run menu and choose “Edit Configurations”
-
Select your Java Application on the left and enter the following “VM Options”.
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 -Djavax.net.ssl.trustStore="path\to\java_home\bin\FiddlerKeyStore" -Djavax.net.ssl.trustStorePassword="password_used_during_keystore_creation"
-
Press OK, Apply, and Run the App.