菜鸟教程小白 发表于 2022-12-11 17:00:55

iOS webview ssl 连接 (kCFStreamErrorDomainSSL, -9843)


                                            <p><p>iOS9.3 xcode7.3.1
我想用 WebView 访问一个 HTTPS 站点,出现错误(kCFStreamErrorDomainSSL, -9843)</p>

<pre><code>NSMutableURLRequest* request = [ initWithURL:];
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 = ;
;
</code></pre>

<p>当我意识到代理</p>

<pre><code>- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSString* str = request.URL.scheme;
    if () {
      if (isOK == NO) {
            originrequest = request;
            NSURLSessionConfiguration* con = ;
            con.requestCachePolicy = NSURLRequestUseProtocolCachePolicy;
            NSURLSession* urlsession = ];
            task = [urlsession dataTaskWithRequest:request completionHandler:^(NSData* _Nullable data, NSURLResponse* _Nullable response, NSError* _Nullable error) {
                NSString* str = [ initWithData:data encoding:NSUTF8StringEncoding];
                NSLog(@&#34;%@&#34;, str);
            }];
            ;
            ;
            return NO;
      }
    }
return YES;
}
</code></pre>

<p>我已经在 info.list 中添加了</p>

<pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
    &lt;dict&gt;
    &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
    &lt;true/&gt;
    &lt;/dict&gt;
</code></pre>

<p>有没有什么办法可以用HTML在服务器上显示XX webView?
请帮帮我!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>试试这个</p>

<pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
&lt;dict&gt;
    &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;NSExceptionDomains&lt;/key&gt;
    &lt;dict&gt;
      &lt;key&gt;example.com&lt;/key&gt;
      &lt;dict&gt;
            &lt;key&gt;NSExceptionAllowsInsecureHTTPLoads&lt;/key&gt;
            &lt;false/&gt;
            &lt;key&gt;NSIncludesSubdomains&lt;/key&gt;
            &lt;true/&gt;
      &lt;/dict&gt;
      &lt;key&gt;insecure.example.com&lt;/key&gt;
      &lt;dict&gt;
            &lt;key&gt;NSExceptionAllowsInsecureHTTPLoads&lt;/key&gt;
            &lt;true/&gt;
      &lt;/dict&gt;
    &lt;/dict&gt;
&lt;/dict&gt;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于iOS webview ssl 连接 (kCFStreamErrorDomainSSL, -9843),我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38473596/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38473596/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS webview ssl 连接 (kCFStreamErrorDomainSSL, -9843)