Certificate pinning in Alamofire

后端 未结 2 606
自闭症患者
自闭症患者 2021-02-08 09:28

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

2条回答
  •  旧巷少年郎
    2021-02-08 09:35

    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.

提交回复
热议问题