Suraj Shaha
Suraj Shaha

Reputation: 31

Sending Request to IIS from Phonegap (SSL/TLS) error

I have asp.net site (https) hosted on IIS.My phonegap app on Mac machine(for iOS) is in same local network. This website act as a handler for this phonegap app's request,but I am not able to debug (i.e send a request to the machine hosting website in local network).I don't think this is External URL or whitelisting issue,but it appears to be SSL/TLS issue,it is not able to proceed because of this certificate error.

How to resolve this,Please help. I am not familiar with objective C environment. any Ideas on how to resolve this issue.

Any help would be greatly appreciated.

Regards, Suraj

Upvotes: 0

Views: 585

Answers (1)

Jageen
Jageen

Reputation: 6365

You have to deal with NSURLConnection delegation as your domain is local your application not trust your certificate. this code will help you to accept any certificate.

- (BOOL)connection:(NSURLConnection *)conn canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
        // A delegate method called by the NSURLConnection when something happens with the
        // connection security-wise.
        {
            NSLog(@"%@",protectionSpace.authenticationMethod);
            return YES;
        }   

        // Called if the HTTP request receives an authentication challenge.
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
            if([challenge previousFailureCount] == 0) {
                NSURLCredential *newCredential;
                newCredential=[NSURLCredential credentialWithUser:self.username password:self.password persistence:NSURLCredentialPersistenceNone];
                [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
            } else {
                [[challenge sender] cancelAuthenticationChallenge:challenge];
            }
        }



or use this reference
How to use NSURLConnection to connect with SSL for an untrusted cert?

Upvotes: 1

Related Questions