gpt4 book ai didi

iOS webview ssl 连接(kCFStreamErrorDomainSSL,-9843)

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:59:03 28 4
gpt4 key购买 nike

iOS9.3 xcode7.3.1我想使用 WebView 访问 HTTPS 站点,出现错误(kCFStreamErrorDomainSSL, -9843)

NSMutableURLRequest* request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"https://52.197.95.84/ResonaIgonWeb/index.html"]];
request.allowsCellularAccess = YES;
request.timeoutInterval = 7.0;
self.myWebview.delegate = self;
self.myWebview.scrollView.showsHorizontalScrollIndicator = NO;
self.myWebview.scrollView.showsVerticalScrollIndicator = NO;
self.myWebview.scrollView.backgroundColor = [UIColor whiteColor];
[self.myWebview loadRequest:request];

当我实现代理的时候

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString* str = request.URL.scheme;
if ([str isEqualToString:@"https"]) {
if (isOK == NO) {
originrequest = request;
NSURLSessionConfiguration* con = [NSURLSessionConfiguration defaultSessionConfiguration];
con.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
NSURLSession* urlsession = [NSURLSession sessionWithConfiguration:con delegate:self delegateQueue:[NSOperationQueue mainQueue]];
task = [urlsession dataTaskWithRequest:request completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable response, NSError* _Nullable error) {
NSString* str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"%@", str);
}];
[task resume];
[webView stopLoading];
return NO;
}
}
return YES;
}

我已经在info.list中添加了

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

有没有什么办法可以用HTML在服务器上显示XX webView?请帮助我!

最佳答案

试试这个

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>insecure.example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>

关于iOS webview ssl 连接(kCFStreamErrorDomainSSL,-9843),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38473596/

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