SecCertificateCopySubjectSummary: How to get Certificate Information in human readable form?

Viewed 649

All,

I was able to get the SecCertificate object of representing an X.509 certificate. My goal is to get the rest of the certificate information in a human readable format. This is what I have so far:

func urlSession(_ session: URLSession, task:URLSessionTask, didREceive 
challenge: URLAuthenticationChallenge, completionHandler: @escaping 
(URLSession.AuthChallengeDisposition, URLCredential?) -> Void {

   let serverTrust:SecTrust = challenge.protectionSpace.serverTrust!
   let certificate: SecCertificate = SecTrustGetCertificateAtIndex 
   (serverTrust, 0)!

   let summary = SecCertificateCopySubjectSummary(certificate)

   print("Cert summary: \(summary)")

}

As a print out I am getting just the Common Name of the certificate in the human readable format, however I am missing the rest of the certificate information. I would really appreciate if you can help me to resolve this problem.

Thanks,

1 Answers

Me too i'm getting the same thing, the certificate common name. You can get more information about your certificate using other copy functions like SecCertificateCopyEmailAddresses, see this link : certificate email. In macOs you can also find certificate copy long description function.

Related