Easwaramoorthy Kanagaraj
Easwaramoorthy Kanagaraj

Reputation: 4213

Ajax https call in ios using PhoneGap not working?

I could not able to do https POST call using ajax from ipad/iphone. Actually I am trying to call this in my PhoneGap application.

Could you please help me in this regard.

Upvotes: 17

Views: 14110

Answers (3)

Pat
Pat

Reputation: 31

TDeBailleul,

Your code seems to work for an anonymous area of the web server, but doesn't work for myself in an Authorized area (cgi.auth_user) with Basic/NTLM authorization.

PhoneGap for iOS FAQ Q. Can I do AJAX with servers that have self-signed certificates? A. No, this is a iOS SDK limitation with UIWebview. You'll have to write an Objective-C plugin.

http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ

Upvotes: 3

Titouan de Bailleul
Titouan de Bailleul

Reputation: 12949

Did you try to add this at the end of you AppDelegate.m file

@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
    return YES; 
}
@end

Upvotes: 36

jordan koskei
jordan koskei

Reputation: 2789

You have not stated the kind of certificate on the server. I suspect that it is self signed. I have also had the same problem. Doing Ajax calls to a server with self signed certificated is NOT possible and this is a SDK limitation. You must write an Objective C plugin to go around this.

Upvotes: 11

Related Questions