I am creating an iPad app that accesses HTTPS web services. I want to implement pinning, but am having issues.
This class creates the Alamofire Manager (mostly taken fro
So, the issue was that the certificate was saved in the wrong format.
ServerTrustPolicy.certificatesInBundle()
finds all certificates in the bundle based on a list of extensions, then tries to load them using SecCertificateCreateWithData
. Per its documentation, this function:
Returns NULL if the data passed in the data parameter is not a valid DER-encoded X.509 certificate
When you export a certificate in Firefox, you have a "format" pop-up at the bottom of the file browser. Select "X.509 Certificate (DER)", and you should get a certificate in the right format for this purpose.