问题
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?
回答1:
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).
回答2:
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:
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.In Charles, the following should be set: Proxy > Proxies 8888
Enable transparent proxying
should be checked; Proxy > macOS Proxy should be checkedIn 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
In the emulator,
Settings > Developer Options > Use legacy DHCP
client should be on.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
来源:https://stackoverflow.com/questions/38505406/how-to-analyze-https-traffic-from-android-6-emulator-with-charles-proxy