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

后端 未结 5 517
星月不相逢
星月不相逢 2021-01-12 11:34

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

I got the following error. This error

5条回答
  •  攒了一身酷
    2021-01-12 12:14

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

提交回复
热议问题