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:
- Get a copy of the remote peer's certificate ...
- Get the server certificate from the trust object (pass an index of 0 to SecTrustGetCertificateAtIndex)
- Get the data for that server certificate (SecCertificateCopyData)
- 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?