Capture HTTPS Traffic With Fiddler in Java

Shubham Vora Nov 04, 2022
  1. Configure the Fiddler
  2. Generate a KeyStore
  3. Configure the Application Code to Capture HTTPS Traffic With Fiddler
  4. Configure the Eclipse to Capture HTTPS Traffic With Fiddler
Capture HTTPS Traffic With Fiddler in Java

The Fiddler is a web debugging proxy tool that helps developers to debug web applications. It allows to capture of network traffic and monitor incoming and outgoing data.

This article will teach us to set up the Fiddler to capture HTTPS traffic. So, users can capture the HTTPS traffic with Java without any error.

Configure the Fiddler

Users should follow the below steps to configure the Fiddler.

  • Download the Fiddler here and install it to your local computer.
  • Now, ensure that Fiddler captures the HTTPS traffic, as shown in the image below.

    capture https with fiddler - 1

  • Next, open the Tools > Options. It will pop-up a dialog box. Go to the Connections tab.
  • Now, ensure the value of the Fiddler listens on port text field, which we will use in our Java code. The default value of it is 8888.

    capture https with fiddler - 2

  • In the Options dialog box, go to the HTTPS tab and ensure that Capture HTTPS Connects and Decrypt HTTPS Traffic are checked. Also, select ...from all processes in the dropdown menu of Decrypt HTTPS Traffic.

    capture https with fiddler - 3

  • Next, install the certificate.
  • As a final step, in the HTTPS tab of the Options dialog, click on the Actions button and select the Export Root Certificate to Desktop to export the certificate on the desktop of your device.

    capture https with fiddler - 4

Generate a KeyStore

We must generate a KeyStore with the certificate we have exported to the desktop.

  • Run the Command Prompt as an administrator.
  • Users need to enter the below command to the terminal to find the root directory.
    echo %JAVA_HOME%
  • Inside the terminal, go to the root directory of Java which you got in the above step.
  • Next, go to the bin folder of the Java directory using the cd bin command in the cmd.
  • Run the below command to the terminal.
    keytool.exe -import -file C:\Users\\\Desktop\\FiddlerRoot.cer -keystore FiddlerKeystore -alias Fiddler
  • Enter the password, and then you must confirm it by re-entering it.
  • Press y to answer the Trust this certificate.

Configure the Application Code to Capture HTTPS Traffic With Fiddler

We have set up the Fiddler and generated a KeyStore with the certificate. Users need to add the code below to the application to capture the HTTPS traffic with Java.

// To capture HTTPS traffic
System.setProperty("https.proxyHost", "");
System.setProperty("https.proxyPort", "8888");
// To capture HTTP traffic
System.setProperty("http.proxyHost", "");
System.setProperty("http.proxyPort", "8888");

Also, users can use the localhost instead of If users want to use a different port than 8888, they also need to change the port inside the Fiddler, which we have explained in the Configure Fiddler section.

Configure the Eclipse to Capture HTTPS Traffic With Fiddler

If users want to configure Eclipse IDE to capture HTTPS traffic rather than adding the code to the application, they should follow the below steps.

  • Go to Run > Run Configurations from the menu bar.
  • From the sidebar of the Run Configurations dialog box, choose a project and go to the Arguments tab.
  • Enter the arguments below in the VM Arguments section.

    capture https with fiddler - 5

  • Now, click the Apply button and press the Run button.

We have successfully set up the Fiddler to capture HTTPS traffic in this article. Also, we have generated the KeyStore using the fiddler certificate.

After that, we have two choices to capture HTTPS traffic using a Java application. The user can either set up Eclipse or add code to the application code.

Author: Shubham Vora
Shubham Vora avatar Shubham Vora avatar

Shubham is a software developer interested in learning and writing about various technologies. He loves to help people by sharing vast knowledge about modern technologies via different platforms such as the website.

LinkedIn GitHub