Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to analyze https traffic from Android 6 emulator with Charles Proxy

I want to analyze the https traffic of the app I am developing for Android.
Charles Web Debugging Proxy is the tool I want to use for that. I have the following system configuartion:

  • Mac OS X El Capitan Version 10.11.5
  • Android Studio 2.1.2
    • Build #AI-143.2915827, built on May 26, 2016
    • Android SDK Tools 25.2.0 rc1
    • Platform Version: API 24: Android 6.X (N) revision 2
  • Charles Web Debugging Proxy v 3.11.5 30 day trial version

I already read several posts on StackOverflow like e.g.

  • SSL Proxy/Charles and Android trouble
  • How to setup Android Lollipop emulator with Charles Proxy?

But still I didn't reach my goal. I walked through all the important steps:

  • Charles Root Certificate installed and added to Max OS X Keychain and trusted
    • Open Proxy Settings: Proxy -> Proxy Settings, Proxies Tab, check "Enable transparent HTTP proxying"
    • Open SSL Proxy Settings:Proxy -> SSL Proxy Settings, SSL Proxying tab, Check “enable SSL Proxying”
  • Android Emulator started from Android Studio Terminal by ~/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -http-proxy <IP_FROM_DEVICE_WITH_CHARLES_PROXY_INSTALLED>:8888 -avd Nexus_5_API_23
  • Certificate installed from http://charlesproxy.com/getssl
  • OR Certificate saved by Charles Proxy, converted to .crt by openssl and installed on emulated device

I can read all the http traffic in Charles Proxy without any problems. I also can read the https traffic but Charles only lists IP addresses. There are entries like

https://173.194.65.188:5228

So the ip addresses are not resolved. How to get real https URLs? Do I have to activate DNS for https somewhere?

like image 566
unlimited101 Avatar asked Jul 21 '16 13:07

unlimited101


People also ask

How do I trust Charles certificate on Android?

In Charles go to the Help menu and choose "SSL Proxying > Install Charles Root Certificate". Keychain Access will open. Find the "Charles Proxy..." entry, and double-click to get info on it. Expand the "Trust" section, and beside "When using this certificate" change it from "Use System Defaults" to "Always Trust".

How do I enable https in Charles?

Open Charles. Go to Proxy > Proxy Settings > SSL. Check “Enable SSL Proxying” Select “Add location” and enter the host name and port (if needed)


2 Answers

I too found this to be an issue. My solution when I want to debug network traffic via Charles Proxy, is to switch over to Genymotion emulator. The Genymotion emulator will give you the url(s) vs. ip(s) in Charles.

In the Genymotion emulator you configure the Wifi proxy hostname to '10.0.3.2' and Proxy port enter '8888' (*assuming port 8888 is the listening port you have configured in Charles Proxy).

like image 137
Jason Grife Avatar answered Sep 21 '22 12:09

Jason Grife


There are instructions that make the Android emulator work with Charles here:

https://stackoverflow.com/a/35577864/2832027

It is quite unreliable. You need to put the emulator in and out of airplane mode if it was working and then stops working.

Here are the steps from the above post:

  1. Start the emulator from the terminal with /{path to your android sdk directory}/tools/emulator -avd Nexus_5X_API_23 -http-proxy http://192.168.2.38:8888 where the -avd value is the name of your emulator and the -http-proxy value is the ip address from Charles: Help > SSL Proxying > Install Charles Root Certificate on a Mobile Device or Remote Browser.

  2. In Charles, the following should be set: Proxy > Proxies 8888 Enable transparent proxying should be checked; Proxy > macOS Proxy should be checked

  3. In the emulator, `Settings > More (Wireless > Cellular Networks > Access Points > T-Mobile US (or whichever other network is there) set Proxy to 10.0.2.2 and port to 8888

  4. In the emulator, Settings > Developer Options > Use legacy DHCP client should be on.

  5. In the emulator, turn Airplane mode on and off

Also, see this if you have issues getting Charles working on Android 7 (API 24) and above. https://android.jlelse.eu/android-nougat-charlesing-ssl-network-efa0951e66de

like image 38
TTransmit Avatar answered Sep 22 '22 12:09

TTransmit