CoXier
CoXier

Reputation: 2663

Charles monitor terminal request

Is there any way to monitor request of application such as terminal? Now I can monitor chrome but other application not.

My charles's version is 4.2

Upvotes: 8

Views: 5388

Answers (1)

Lluís Suñol
Lluís Suñol

Reputation: 3651

I think it depends on the command line you are trying to monitor. To purely capture http requests made from terminals you just need to set the environment variable 'http_proxy' such as:

$ export http_proxy="http://localhost:8888"
$ curl "http://www.google.com"

This will make Charles capture the HTTP request to Google, but this may not happen with all applications started from this terminal. You'll probably have to find the way to configure the proxy on those other applications.

Just as an example, if you want to capture http requests from a java application you are developing, you will need to add the proper proxy configuration to the java command line, something like:

$ JAVA_FLAGS="-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=8888"
$ java $JAVA_FLAGS ...

To enable HTTPS sniffing with Charles you will need to add the certificate to the JVM's keystore with:

$ keytool -import -alias charles -file charles-ssl-proxying-certificate.cer -keystore $JAVA_HOME/jre/lib/security/cacerts

Please, notice that

  • the cacerts file location may vary depending on the java version (on Java 10 it's under $JAVA_HOME/lib/security/)
  • the password for the cacerts file, if unchanged, is: changeit (so consider changing it)

Hope this helps.

Upvotes: 18

Related Questions