Display untrusted certificate information in an iOS application

In my iOS application, I am trying to connect to a server with an untrusted certificate.

I handle this situation by following the procedure specified in this URL:

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/urlloadingsystem/Articles/AuthenticationChallenges.html

This works fine.

Now I have one requirement in which I need to show details related to certificates, such as:

  • Name
  • Location
  • Organization Unit
  • E-mail address
  • Not valid until date
  • Invalid after date
  • Signature algorithm

Now I have a few questions:

Q1. How can I get the above credited information? Is there any cocoa API to provide the same?

Q2. , - , . iOS?

.

+4
2

Q1: fooobar.com/questions/207715/... . , , .

Q2: - , ( ), , SHA1 MD5 , (, ).

, , NSURLConnectionDelegate NSURLConnectionDataDelegate ( )

:

- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
    NSLOG(@"connection canAuthaenticateAgainstProtectionSpace");
    if (![Certificates verifyProtectionSpace:protectionSpace]) { //this to verify your own certificate which is self signed.
        NSLOG(@"Bad Certificate, canceling request");
        [connection cancel];
        self.ended = true;
        return false;
    }
    return true;
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    NSLOG(@"connection didReceiveAuthenticationChallenge");
    if ([Certificates verifyProtectionSpace:challenge.protectionSpace]) { //this is where you verify the certificates again - for non self-signed ones usually.
        [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
    } else {
        [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
    }
}
+1

All Articles