Reputation: 7897
I am writing a phonegap application that works against a RESTful api. For purposes of debugging, I would like to see what my POSTs and GETs look like. All information on google says to use a fiddler proxy. I got fiddler installed and work, setup my android emulator to use it, but whenever I start querying the restful service the packets get mangled somehow (or at least the authorzation portion of it).
If I do not have the proxy going, the following JS code works fine in my android emulator:
$.post("https://blah.hi.com/homepage/security_check",
$("#loginForm").serialize(), function (data, textStatus, jqXHR) {...
But when I have fiddler going, so that I can analyze the requests my android app is making, I get the following error:
As far as I can tell from inspecting the initial request in fiddler the following changes are made:
User-Agent, Connection, and Host headers are stripped. I tried adding them in manually, using Fiddler rules, but that didnt work.
Here is a good comparison:
Also, when I look at the TextView tab of the request, the following headings under Extensions are stripped (the following is a picture of what the request looks like when using Chrome, and going through fiddler, and works):
Now here is it when going through the eclipse android emulator, through fiddler, and fails:
I thought about using WireShark, but all the communication is done over https, and would prefer to use fiddler.
Any advice would be greatly appreciated!! Also, I get to the proxy by using the following argument -http-proxy 127.0.0.1:8888 from here http://vkosinets.com/blog/2011/08/16/debug-http-requests-from-android-emulator
EDIT: Here is some debug information when using the Android 4.X emulator (which also fails).
Upvotes: 4
Views: 1836
Reputation: 41126
It is very likely an issue reported against the old Android SDK/Emulator version:
Issue 12356: lost header on https connection via proxy
Also worth to check the missing header discussion in the related issue:
Issue 3334: SSL web sites fail to load in browser application when not connected via Wi-Fi
According to this post, it seems that this issue only exist on Android 3.x and lower versions:
this problem is ONLY occuring on Android 3.x and lower versions. iOS is fine. All major desktop browsers are fine. Android 4.x is fine.
Try using Android 4.x emulator and see if that works.
It is probably a configuration challenging other than an unclear bug in some situation. Check out Setting up a persistent trusted CA in an Android emulator:
Setting up a persistent trusted CA in the Android emulator is a common problem, encountered any time we assess an application within an emulator, that use SSL properly. The goal is to man-in-the-middle (MITM) traffic from an application running in the Android emulator.
In order to successfully MITM traffic, the Certificate Authority (CA) of the middle node must be trusted by the device, otherwise the connection will fail with some generic SSL Handshake error. Typically, the middle node can be flagged as trusted on a rooted phone by modifying the cacerts file, and rebooting the device. When attempting to do this in the Android emulator, rebooting the virtual device causes the OS to revert many system files back to their base state – including the cacerts file. The rest of this post describes how to set up an emulator that will retain modifications to the core system files after reboots. This has not been documented in one place (to my knowledge), so hopefully this will save time for those facing this problem.
... ...
Upvotes: 1