I am writing a web application in Java using IntelliJ, and I would like to monitor all my http/https requests using Charles, however my requests do not show up by default, so I am suspecting that some proxy settings need to be set up on both sides. Can someone explain it in details? Thanks a lot in advance!
-
what http requests? From intellij idea itself, or your app? – Sergio Tulentsev Oct 25 '17 at 07:56
-
1I'd like to monitor requests made by my app. However as I only need this for testing purposes, I'd prefer to set up these proxy configurations in IntelliJ, and not in the project itself. – Gábor Pintér Oct 25 '17 at 08:46
3 Answers
Ok so, I have managed to understand the problem and also solve it.
JVM proxy
The first issue was that my requests were essentially coming from the JVM, so that's why we have to proxy them first, which means a JVM configuration has to be made, which can be provided as arguments (can be provided through CLI or under VM options in IntelliJ) like so:
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888
HTTPS
The next issue was that along with this proxy, certificates also have to be provided in order to capture and view decrypted https requests.
We can generate Fiddler certificates by going to Tools > Options > HTTPS > Decrypt HTTPS traffic. The generated cert can be downloaded from http://127.0.0.1:8888/.
Using JVM's keytool, we can create a new keystore using our certificate, which we can use later as a JVM configuration to trust resources. To do so, run the following command (make sure to provide the right paths for the keytool and the cert):
"C:\Program Files\Java\jdk1.8.0_144\bin\keytool.exe -import -file C:\Users\Username\Desktop\FiddlerRoot.cer -keystore FiddlerKeystore -alias Fiddler
After providing a password, the keystore will be generated at C:\Windows\System32
.
Now, we can provide this keystore and password to the JVM by passing the following:
-Djavax.net.ssl.trustStore="C:\Windows\System32\FiddlerKeystore" -Djavax.net.ssl.trustStorePassword="yourKeyStorePassword"
This answer was based on the following blog post and StackOverflow answer:

- 981
- 2
- 9
- 24
-
2This works the same with Charles Proxy: set the JVM proxying (`-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888`), then install the Charles Certificates in Charles > Help > SSL Proxying > Instal Charles Root Certificate. – Gábor Pintér Jan 10 '18 at 08:19
-
I didn't find the keystore generated at `C:\Windows\System32`... is it possible that it's generated to somewhere else? – Chen Ni Jun 29 '21 at 07:52
Following these directions on the official site:
https://www.charlesproxy.com/documentation/using-charles/ssl-certificates/
Export the Charles Proxy root certificate.
Install the certificate into the JVM certificate store for the Java version that your application in IntelliJ is using.
sudo keytool -import -alias charles -file ~/Desktop/charles-ssl-proxying-certificate.pem
The issue I had was that the IntelliJ run 'configuration' (for running the Java application from inside IntelliJ) was using a different SDK to the actual Project level SDK.
Go to Edit Configurations in IntelliJ to confirm the SDK being used at runtime.
Edit: I also found that some libraries (sp. Apache HttpClient) bypass the configure SDK/Proxy settings, leading to requests from IntelliJ that are not visible to Charles Proxy.

- 3,542
- 30
- 46
Charles has already supported JVM proxy. So all you have to do is:
- install certificate for jvm;
- set jvm proxy;
I will describe the details below:
1 install certificate for jvm
This can be done by:
Help -> SSL Proxying -> Install Charles Root Certificate In Java VMs
Note that Charles use 8888 port by default, if your proxy port is not 8888, just input your own proxy port.
2 set jvm proxy
You can set jvm proxy by two ways, java code or program arguments, show as the below code:
// method 1: use the java code
System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", "8888");
// method 2:use the program arguments
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888
-
in Charles v4.5.6. under Help -> SSL Proxying,there is no "Install Charles Root Certificate In Java VMs" option – Venus Feb 25 '22 at 08:55
-
I am using Charles v4.2.8(as shown in the image above),and there is a "Install Charles Root Certificate In Java VMs" option。 Maybe it is a version problem ? – wxweven Feb 26 '22 at 14:43