Skip to content

Instantly share code, notes, and snippets.

@t0rr3sp3dr0
Last active March 17, 2022 05:20
Show Gist options
  • Save t0rr3sp3dr0/83c1ad8087eaf3dfc09f23e085b2f0de to your computer and use it in GitHub Desktop.
Save t0rr3sp3dr0/83c1ad8087eaf3dfc09f23e085b2f0de to your computer and use it in GitHub Desktop.
public class Delegate: NSObject, URLSessionDelegate {
public func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
let serverTrust = challenge.protectionSpace.serverTrust!
let exceptions = SecTrustCopyExceptions(serverTrust)
SecTrustSetExceptions(serverTrust, exceptions)
completionHandler(.performDefaultHandling, URLCredential(trust: serverTrust))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment