gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 09:45:52 30 4
gpt4 key购买 nike

我有一个 url which domain.com/map.jsp 这是一个 JSP 页面,它显示带有自定义标记的谷歌地图,用于编写一些 javascript 代码。当我在设备上加载此页面时,它显示错误为 < strong>NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9814)。但它在 iOS 模拟器上运行良好。

我在谷歌上搜索了很多,但没有解决方案。

1.再见传递url

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

2.仅指定 url。我不能对 url 进行硬编码,因为 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 设备上无法运行但在模拟器上运行良好。解决方案是什么?

最佳答案

我的 iPad 的日期/时间设置有问题。首先我尝试在 iPad 上的 chrome 上打开 google.com,然后它显示不安全的网络错误。所以我更改了 iPad 的日期/时间设置,我的问题得到解决。

关于javascript - 加载 web View 中的 NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9814)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38919459/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com