SwiftHTTP icon indicating copy to clipboard operation
SwiftHTTP copied to clipboard

SSL Pinning - Always failing

Open nilecoder opened this issue 4 years ago • 0 comments

What's the problem?

Trying to load a self signed certificate like so:

    if let certPath = Bundle.module.url(forResource: "theCert", withExtension: "cer") {
            let certData = try! Data(contentsOf: certPath)
            let cert = SSLCert(data: certData)
            task.security = HTTPSecurity(certs: [cert], usePublicKeys: false)
}

 task.run { (response) in
            if let err = response.error {
                print("error: \(err)")
                return
            }

       // Do work
}

I have also tried using the SecKey initializer and even though I get back a valid value, pinning always fails. The task is canceled and I'm not sure why.

Can you lead me in the right direction? Thank you for your time.

nilecoder avatar Nov 15 '21 04:11 nilecoder