我正在尝试从 webview 加载 php 脚本,但每次都会出现错误。
NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9814)
我已经将 info.plist 更新为
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
帮我看看我哪里出错了。
这是我的代码
func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let str : NSString = request.URL!.absoluteString
let url = NSURL(string: request.URL!.absoluteString)
if (str.rangeOfString("https://testing.com/paymethod2.php").location != NSNotFound)
{
}
else
{
webView.stopLoading()
}
return true
}
func webViewDidFinishLoad(webView: UIWebView) {
let doc = webView.stringByEvaluatingJavaScriptFromString("document.documentElement.outerHTML")
print(doc)
}
谢谢
最佳答案
9814 是 errSSLCertExpired。更新您的证书。如果您正在使用一些自签名证书,并且您确实希望它在已过期的情况下仍然有效,请阅读此文档:
关于ios - (kCFStreamErrorDomainSSL,-9814),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36569937/