ios - (kCFStreamErrorDomainSSL,-9814)

标签 ios swift nsurlsession

我正在尝试从 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。更新您的证书。如果您正在使用一些自签名证书,并且您确实希望它在已过期的情况下仍然有效,请阅读此文档:

https://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/OverridingSSLChainValidationCorrectly.html

关于ios - (kCFStreamErrorDomainSSL,-9814),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36569937/

相关文章:

ios - 将 NSURLProtocol 与 NSURLSession 一起使用

ios - GCDWebserver 监听 HTTP POST

swift - 我可以/如何用 RC3 替换我的 KVO 东西?

ios - 将网络操作分组到一个 swift 文件中 - iOS

ios - 将 SCNNode 旋转到用户点击的位置

swift - 将 Swift 结构转换为 UnsafeMutablePointer<Void>

ios - NSURLSession 不使用缓存响应

ios - 无法在 ios 模拟器上运行我的 flutter 应用程序

iphone - 找不到 cap_ios.h

ios - 如何从URL确定文件的文件扩展名(Objective-C)