Proxy and SSL connections in android emulator

2019-07-21 08:14发布

问题:

Would anyone know how to configure the emulator to make ssl connections via a proxy ?

I use the -http-proxy option when starting the emulator. I can access any website except those with https protocol.

Any idea ?

回答1:

I've experienced similar problems with Android during a web project lately. The site works fine using ordinary HTTP from Android but when using HTTPS it works now and then. Some requests just fail and we get "Web page not found"-errors. The connections are sometimes very slow. After some further tests and investigation I found out that the problem was general for all HTTPS sites, not only for our site.

According to a bug report for Android others are reporting the same problem and Android has been hit by it since version 1.5: http://code.google.com/p/android/issues/detail?id=3334

I removed the APN proxy in my HTC Desire, as stated in the bug report above, and then Android performed as expected on HTTPS sites. For our purpose we have made an exception for Android telephone so they are routed to the ordinary HTTP site instead.

In other words, it seems like Android has a general problem with proxies and that may be the cause of problem with the emulator. Vote on the bug, just follow the link above.



回答2:

There are several possible reasons for that:

  • Can you access the HTTPS site with your real phone? If not, then probably the involved certificate is not considered as trusted from the app/webview. If you need to consider a certificate as trusted within your app, look at the following tutorial
  • Can you access HTTPS sites at all via your proxy from a webbrowser? Our enterprise proxy server does not allow HTTPS traffic (for whatever reason) at all. You could also sniff the traffic with Wireshark etc. to see if anything is sent back from the proxy or an error occurred.

What type of problem did you get when you try to connect to the website? Can you provide a stacktrace or LogCat output?