# Capture HTTPS Traffic With Fiddler in Java

Shubham Vora Nov 04, 2022

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.

## Generate a KeyStore

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

• ##### Users need to enter the below command to the terminal to find the root directory.
echo %JAVA_HOME%

• ##### Run the below command to the terminal.
keytool.exe -import -file C:\Users\\\Desktop\\FiddlerRoot.cer -keystore FiddlerKeystore -alias Fiddler


## 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", "127.0.0.1");
System.setProperty("https.proxyPort", "8888");
// To capture HTTP traffic
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");


Also, users can use the localhost instead of 127.0.0.1. 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.

• ##### Enter the arguments below in the VM Arguments section.
-DproxySet=true
-DproxyHost=127.0.0.1
-DproxyPort=8888
-Djavax.net.ssl.trustStore="path\to\java_home\bin\FiddlerKeyStore"

• ##### 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.