-->

Charles proxy SSL connections won't show hostn

2019-03-09 21:00发布

问题:

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:

Urls instead of IP Addresses

To see the actual URLs those IPs represent, we can tweak our emulators settings to play nice with Charles.

To do this, go to your Emulator’s device settings, then go to (on Android 8.0, anyway) Network & InternetMobile networkAccess Point Names.

Now you can edit the Proxy and Port settings to match what we entered earlier in the Emulator’s settings. When you’re done that, don’t forget to click the three dots in the toolbar and Save your changes. Now, take a look at Charles again. If you’ve set up your app to trust the Charles cert, you should start to see some api urls in there.

Please follow a full instructions here - https://medium.com/@daptronic/the-android-emulator-and-charles-proxy-a-love-story-595c23484e02