Proxy and SSL connections in android emulator - android

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 ?

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.

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?

Related

How to inspect network requests and responses happened in Android System WebView remotely?

Recently I have a problem in inspecting network requests and responses happened in Android System WebView.
The problem is that our app sometimes failed to load some urls with Android System WebView, but we can not get enough information to trace these cases.
Tools like Fiddler or Charles have some limitations like I should have access to that Android device, right?
And I also tried tools like Chrome Remote Debugging, this tool was amazing to debug problems in Android System WebView, but I should have Android device and development machine connected via USB, right?
So, is there any helpful things for me to inspect network requests and responses happened in Android System WebView remotely?
Thanks all.
Use Charles Proxy for inspecting network requests, it is pretty easy to use
this article will help
https://medium.com/#hackupstate/using-charles-proxy-to-debug-android-ssl-traffic-e61fc38760f7
add ssl proxy settings for the domain you want so that you can see the responses and requests clearly with headers and value you are sending in the body or in headers
if you want only remote debugging in chrome for webview
follow this
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/?utm_source=dcc&utm_medium=redirect&utm_campaign=2016q3

Using Fiddler2 HTTP request inspector with an Android device

For a project working I need to inspect the HTTP requests sent and received from my Android device. I'm using this tool Fiddler2 to monitor the traffic. In order to get it working I had to pass the traffic through a proxy. Now my phone is a Huawei U8180. Its runs Android 2.2 so it doesn't have a direct way to proxy settings. I used this app called Proxy Settings to gain access to set the proxy settings.
It almost works. I can see the traffic say, if I navigate to a website using the proxy web browser in that app (The app comes with a proxy browser). But not using my phone's normal browser. Neither I can see any HTTP requests sent by any of my apps installed in my device.
If anyone has any experience using Fiddler2 with Android, I'd really appreciate your input. I'm open to try any other alternatives to accomplish this if you got any.
Thanks.
Typically, Android users will use a tool like iptables to capture traffic from apps that don't support a proxy setting. This has some implications for HTTPS decryption; see the Fiddler Discussion Group (Help > Fiddler Community) for discussion of how to adjust Fiddler's HTTPS settings to accommodate iptables-redirected HTTPS connections.

unable to connect to https site on via both code and native browser

I have an android application that makes a https connection to a backend. I have successfully added the required certificate (obtained from the backend and converted to bks format) and the app can connect when running on 2.2, 2.3 and 4.0.2 emulators. However on my huawei u8860 (honor) with ics 4.0.3, the app doesn't connect and worst of all it doesn't give any exceptions in the log. On the phone also, I can't point the native browser to the backend but i can using google-chrome for android. I've searched high and low on but found no explanation for this behaviour. any ideas?! Thanks in advance
I suspect the problem is caused by your mobile carrier.
Some of them perform nasty filtering of HTTP requests, based on the User-Agent header (they'll block requests that do not seem to come from a mobile device).
You should try your app on your phone, using a Wifi connection to confirm/infirm this hypothesis.
If it works on Wifi, you should try to change the User-Agent of your HTTP requests, by either setting it to:
A hard-coded Android Chrome or iPhone Safari User-Agent (that you carrier probably does not block)
The User-Agent of your own device's browser that you should get with getUserAgentString()

Inconsistent HttpUrlConnection behaviours on Android - how to debug?

I have a weird problem:
Implementing an interface to a webserver in my Android App, I connect to it using a HttpsUrlConnection. The connection uses additional HTTP Basic authorization (using setRequestProperty), but otherwise is a plain GET request over HTTPS.
It works perfectly fine using it on the emulator using Android 4.0.3, but fails with a "Bad request" HTTP 400 Error on Android 2.3.5 (both emulator and real device).
I do not have control over the server, so I cannot see what the problem exactly is.
Has anyone ever encountered such a problem or knows how to print/log the request that actually is being sent?
TIA,
Patrick
You could set up a proxy such as Fiddler or Charles proxy (and I think there are firefox extensions as well) and point your app to the proxy instead. Even if you don't set it up to actually be a proxy (such that the requests actually work), as long as it captures the requests you should be able to compare the difference between the requests made from 4.0.3 vs. 2.3.5.

How to configure an HTTP Proxy like Fiddler2 or Charles Web Proxy with the latest Android Emulator on Windows?

I'm at complete odds over configuring a proxy to inspect the HTTP(S) traffic for the app I'm developing. I've tried running Fiddler2 and Charles Web Proxy, both run on 127.0.0.1:888, and starting up the Android emulator with the parameter:
-http-proxy http://127.0.0.1:8888
To test it out I open the Android browser. I see in Fiddler2 that the request is routed through the proxy. However, only RARELY does the request receive a successful response. In most, and when I say most I mean 99% of the time, the request is retried and fails again with the Android browser telling me "The server failed to communicate".
Has anyone found a way to configure Fiddler2 or Charles for debugging HTTP(S) traffic through the Android emulator?
The -http-proxy emulator option works for me (with a real HTTP proxy behind it), so not sure what the problem with Charles would be.
An alternative is to capture the network traffic directly, then analyse it afterwards using Wireshark — which can do SSL decryption, if you have the private key.
I was able to view the traffic with an HTTP sniffer instead of a proxy. I used HTTPScoop, which is a nice little app.
Also the nice thing about using HTTPScoop is that I can also see traffic on my actual device when I turn on internet sharing and have my phone use the wifi from my mac. So this is a good deal for debugging what happens on the phone itself AND the emulator.
This way it doesn't matter what emulator you use, because the sniffer sees the traffic independent of the emulator, device, compiler settings etc.
I had the same problem with Charles using the Emulator from the Android development tools r12. It should be working when you download r11 and replace the emulator in r12 with the one from r11. The bug is tracked here.
To get r11 copy the download link from the download page and change r12 to r11.

Categories

Resources