We are trying to use Apple docs to use your own certificate authority (CA):
Although a self-signed certificate is a smart design, there is a better way: create your own authority certificate ... and issue a certificate for your test server. Then you can ... hardwire your certificate authority certificate into your application
I was not able to figure out how to hard-wire the CA root certificate using Swift. The document mentions an approach but I could not translate it into Swift code:
- Get a copy of the peer remote certificate ...
- Get server certificate from trust object (pass index from 0 to SecTrustGetCertificateAtIndex)
- Get data for this server certificate (SecCertificateCopyData)
- Compare this with the certificate data obtained in step 1; if they match, you speak with the right peer
How can you do this through Swift?
source
share