[英]HTTP load failed in xcode version 9.3 ios 11 even after adding temporary exception on plist file
I am using swift. 我正在迅速。 I saw similar question but there is no answer for that and another but that is using objective c language.
我看到了类似的问题,但是没有答案,而另一个答案是使用客观c语言。
Error log : 错误日志 :
TIC SSL Trust Error [1:0x1c4168340]: 3:0
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9843)
Task <00FBDA7D-E906-4BE2-8862-0AD6CAF1A0D7>.<1> HTTP load failed (error code: -1202 [3:-9843])
Task <00FBDA7D-E906-4BE2-8862-0AD6CAF1A0D7>.<1> finished with error - code: -1202
error
screenshot : 屏幕截图 :
Here's the code from the linked answer in Swift. 这是Swift中链接答案的代码。 HTH.
HTH。
class RequestHelper: NSObject, URLSessionDelegate {
func makeRequest(request: URLRequest, completionHandler: @escaping (Data?, URLResponse?, Error?) ->() ) {
let sessionConfiguration = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfiguration, delegate: self, delegateQueue: nil)
let task = session.dataTask(with: request) { data, response, error in
completionHandler(data, response, error)
}
task.resume()
}
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition,
URLCredential?) -> () ) {
guard
challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust,
challenge.protectionSpace.host == "yourdomain.com",
let trust = challenge.protectionSpace.serverTrust
else {
return
}
let credential = URLCredential(trust: trust)
completionHandler(.useCredential, credential)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.