1

I have a url which domain.com/map.jsp this is a JSP page which shows the google map with custom markers for that some javascript code is written.When i load this page on device then it shows me error as NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9814).but it works fine on iOS simulator.

I have searched a lot about this on google but no solution worked.

1.Bye passing the url

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

2.Specifying the url only.I can't hard code the url because url can be dynamic so below code will not work for me.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourdomain.com</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow HTTP requests-->
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <!--Include to specify minimum TLS version-->
      <key>NSTemporaryExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
    </dict>
  </dict>
</dict>

3.I have added below methods in mywebview class but none of the methods gets called

-(BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:
(NSURLProtectionSpace *)protectionSpace {
    return YES;
}

-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:
(NSURLAuthenticationChallenge *)challenge {
    if (([challenge.protectionSpace.authenticationMethod
          isEqualToString:NSURLAuthenticationMethodServerTrust])) {
        if ([challenge.protectionSpace.host isEqualToString:@"mydomain.com"]) {
            NSLog(@"Allowing bypass...");
            NSURLCredential *credential = [NSURLCredential credentialForTrust:
                                           challenge.protectionSpace.serverTrust];
            [challenge.sender useCredential:credential
                 forAuthenticationChallenge:challenge];
        }
    }
    [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}

Please suggest why it not working on iOS device but it is working fine on simulator.What is the solution?

TechChain
  • 8,404
  • 29
  • 103
  • 228
  • see this http://stackoverflow.com/questions/33127376/ios9-http-connection-error – Anbu.Karthik Aug 12 '16 at 13:45
  • The App Transport Security doesn't work either? Not even allow arbitrary loads? That's weird... Are you sure you entered it into the correct plist file? And regarding the delegate methods: You did set the webView's delegate to your view controller, right? – Gero Aug 12 '16 at 13:48
  • right all other url's are working fine awsome.but only for google map file it is creating issue – TechChain Aug 12 '16 at 13:50
  • Duplicate of http://stackoverflow.com/q/36569937/1633251 - really, all you had to do is google iOS and 9814 – David H Aug 12 '16 at 14:34

1 Answers1

4

It was issue with date/time settings of my iPad.Firstly i tried opening google.com on chrome on iPad then it was showing unsecure network error.So i changed the iPad date/time settings my issue was resolved.

TechChain
  • 8,404
  • 29
  • 103
  • 228