加载webview中的NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9814)?

问题描述:

我有一个网址domain.com/map.jsp这是一个JSP页面,它显示了带有自定义标记的谷歌地图,用于编写一些javascript代码。当我在设备上加载此页面时,它显示我错误为NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9814)。但它在iOS模拟器上正常工作。加载webview中的NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9814)?

我在谷歌上搜索了很多关于这方面的信息,但没有解决方案。

1.Bye网址传递

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

2.Specifying网址only.I不能硬编码的网址,因为URL可以是动态的,所以下面的代码不会为我工作。

<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.我已经添加下面mywebview类的方法,但没有一种方法被调用

-(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]; 
} 

请说明为什么它不工作的iOS设备上,但它是在simulator.What工作的罚款解决方案?

+0

请参阅http://*.com/questions/33127376/ios9-http-connection-error –

+0

应用程序传输安全性也不起作用吗?甚至不允许任意加载?这很奇怪...你确定你把它输入了正确的plist文件吗?关于委托方法:您确实将webView的代理设置为您的视图控制器,对吧? – Gero

+0

对所有其他网址的工作正常awsome.but仅适用于谷歌地图文件它创造的问题 – Techiee

这是我的iPad的日期/时间设置的问题。首先我试图在iPad上的Chrome上打开google.com,然后显示不安全的网络错误。所以我更改了iPad的日期/时间设置我的问题已解决。