4

We're attempting to follow the Apple docs for using your own certificate authority (CA):

While a self-signed certificate is a reasonable approach during development, there is a better way: create your own certificate authority ... and have it issue a certificate for your test server. You can then ... hard-wire your certificate authority's root certificate into your app

I haven't been able to figure out how to hard wire the CA root cert using Swift. The paper mentions an approach but I haven't been able to translate this into Swift code:

  1. Get a copy of the remote peer's certificate ...
  2. Get the server certificate from the trust object (pass an index of 0 to SecTrustGetCertificateAtIndex)
  3. Get the data for that server certificate (SecCertificateCopyData)
  4. Compare this to the certificate data you got in step 1; if they match, you're talking to the correct peer

How can you do this via Swift?

Marcus Leon
  • 55,199
  • 118
  • 297
  • 429

0 Answers0