79540600

Date: 2025-03-28 05:37:00
Score: 1
Natty:
Report link

Thanks to @Tarun, this codes work

    func urlSession(_ session: URLSession,
                    didReceive challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?)
    {
        guard let serverTrust = challenge.protectionSpace.serverTrust,
              let certificates = SecTrustCopyCertificateChain(serverTrust) as? [SecCertificate],
              let certificate = certificates.first
        else {
            return (.cancelAuthenticationChallenge, nil)
        }
        let credential = URLCredential.init(trust: serverTrust)
        
        guard SecTrustEvaluateWithError(serverTrust, nil) else {
            return (.cancelAuthenticationChallenge, credential)
        }
        let cfdata = SecCertificateCopyData(certificate)
...
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Tarun
  • Low reputation (0.5):
Posted by: Alexey Ishkov