SwiftHTTP
SwiftHTTP copied to clipboard
SSL Pinning - Always failing
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.