Ошибка загрузки HTTP в версии 9.3 xos icode 11 даже после добавления временного исключения в файл plist - PullRequest
0 голосов
/ 08 мая 2018

Я использую Swift. Я видел похожий вопрос , но нет ответа на этот вопрос и другой , но он использует объективный язык c.

Журнал ошибок :

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 of plist file

1 Ответ

0 голосов
/ 08 мая 2018

Вот код из связанного ответа в Swift. НТН.

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