NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) iOS

Server is throwing SSL certificate error.
For the sake of testing, you can add the following code to the appDelegate:

+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host {
return YES;
}

This will bypass the SSL error

Note: works for NSURLConnection & UIWebView, but not for WKWebView

Edited:

For iOS 9, above procedure don’t work. Add the following snippet in info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

Leave a Comment