问题
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:
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
回答2:
This means the SSL Certificate has expired. If your SSL Certificate isn't expirted it could be caused by an incorrect Date Time set on your device.
来源:https://stackoverflow.com/questions/36569937/kcfstreamerrordomainssl-9814