问题
I'm using Charles to debug my apps- on both android and ios. something rather strange happens, on the secured connection, after I have installed Charles CA on the devices.
On IOS, Charles will show the request to the hostname in the list of connections, and it looks great.
However, on android, it will only show the IP. I have to open the request and check for the hostname header to figure out the hostname- and that's pretty annoying.
Any way around this?
回答1:
This happens because Android emulator is a VM and not just a mac os process like the iOS simulator. To be able to see hostnames using Android emulator (Tested on Android 8.0) you have to go to Setting -> Network & Internet -> Mobile network -> Access point names -> Click on the access point and set Proxy and Port properties to your charles local address (You can find it on Charles -> Help -> Local IP Address)
UPDATE:
Google has changed this on the last version of Android emulator. Now you have to add a new APN. Just create a new APN with any name and the APN set to "http://", proxy to 10.0.2.2 and port to 8888
回答2:
Emulators for API 25+ have a simulated wifi access point called AndroidWifi: https://developer.android.com/studio/run/emulator#wi-fi
Go to your emulators wifi settings, connect to the AndroidWifi, then hold down on it and select modify network. Enter your Charles Proxy hostname and port. It should connect to the proxy and you should see domain names in the requests.
Don't use the proxy settings provided in the emulator's extended controls.
回答3:
You need to set the proxy settings (IP and port) not using the emulator sidebar but inside the actual settings of Android that runs on the emulator. Just long tap on the Wifi network named AndroidWifi
and then Modify network
. Set the IP to your local computer's IP and port to 8888. Setting an APN is not needed!
来源:https://stackoverflow.com/questions/33724755/charles-proxy-ssl-connections-wont-show-hostnames-only-ips