Skip to content

SSL Pinning - Always failing #309

@nilecoder

Description

@nilecoder

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions