Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix ‘TIC SSL Trust Error’ in iOS?

When I tried to login to the application using a webservice. I also set my plist-file like the following

enter image description here

I got the following error. This error showing on my console

TIC SSL Trust Error [5:0x1c017fbc0]: 3:0
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
Task <E0C414FF-98C7-4E6B-876F-B9006465C8FD>.<1> HTTP load failed (error code: -1200 [3:-9802]
like image 781
IKKA Avatar asked Oct 27 '17 12:10

IKKA


1 Answers

IKKA - s answer in Swift 4.2 version

extension CustomViewController: URLSessionDelegate {
    func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
        if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate) {
            completionHandler(.rejectProtectionSpace, nil)
        }
        if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {
            let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
            completionHandler(.useCredential, credential)
        }
    }
}
like image 197
Ruben Nahatakyan Avatar answered Oct 09 '22 02:10

Ruben Nahatakyan