(kCFStreamErrorDomainSSL, -9814)

2019-05-29 10:03发布

I am trying to load a php script from a webview and am Having an error each and every time.

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9814)

I updated my info.plist already to

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

Help me where I am going wrong.

Here is the code that I have

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)
}

Thanks

1条回答
乱世女痞
2楼-- · 2019-05-29 11:01

9814 is errSSLCertExpired. Update your cert. If you're using some self-signed cert and you really want it to be valid in spite of being expired, read this doc:

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

查看更多
登录 后发表回答