3
votes

I am facing the error while making HTTPS request :-

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813).

I did some google and there were some solutions mentioned to by pass the ATS (Application Transport Security) by mentioning the following key in my project info plist file. This is the issue in iOS9 and above.

**Keys are :-

key :- NSAppTransportSecurity

value : -NSAllowsArbitraryLoads : true**

I have tried this solution. But i am still facing the same issue all the time. I am stuck in this. Can anyone please help me ?

2
Apparently this is happening in ios version > 10. For fix it follow the next link stackoverflow.com/questions/31249559/…jose920405

2 Answers

0
votes

You have to add just the NSAllowsArbitraryLoads key to YES in NSAppTransportSecurity dictionary in your info.plist file.

enter image description here

0
votes

I have fixed my issue by implementing the authentication challenge delegate method of NSURLConnction.

Following implementation fixed my issue.

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
       NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
      [challenge.sender useCredential:credential forAuthenticationChallenge:challenge];

      [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}