I have an iOS application that will be distributed to multiple customers, each using their own network infrastructure. I would like to add some certificate pinning capabilities, but I need to do it in a dynamic fashion since I cannot ship the app with the cert/pubkey bundled, as doing so would require a different build for each customer.
My idea is to query the per-client configured HTTPS server on app startup, get the certificate, potentially extract the public key and then pin it.
Is it possible to do this in Swift or Objective-C? I have not been able to find relevant code samples or documentation.
RNSecTrustEvaluateAsX509
. It includes the code to extract the certificate from the connection. You can then write the certificate out to a file, and later use standard pinning practices like github.com/rnapier/RNPinnedCertValidator. – Tailspin