iOS does not give you very detailed access to certificate information. You have two options: private APIs or creating your own evaluator using OpenSSL.
You can see the private functions of certificates in open source code . A version is available from SecCertificateVersion()
. I'm not sure what you mean by "type of validation" here.
To do this using OpenSSL, you can get DER data using SecCertificateCopyData()
, and then analyze everything yourself.
I suggest opening a radar (bugreporter.apple.com) on this issue. Lack of access to basic certificate information is a serious problem.
If you are looking for sample code that extracts a certificate from NSURLConnection
, see the example code for chapter 11 from iOS: PTL :
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { NSURLProtectionSpace *protSpace = challenge.protectionSpace; SecTrustRef trust = protSpace.serverTrust; ... SecCertificateRef cert = SecTrustGetCertificateAtIndex(trust, 0); ...
At this point, cert
is stored your certificate sheet.
source share