2
votes

In one our iOS application , we are getting SSL error after upgrading iOS device to iOS8.1. Can any one help me ,what is difference between iOS8 and iOS8.1 , ssl certificates is concerned ? What kind of certificates need to be added at server end for iOS8.1 ?

This is the log from console :

: CFNetwork SSLHandshake failed (-9824) : NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)

1

1 Answers

2
votes

You are connecting to a site with untrusted certificate. About the error code:

Its error domain kCFStreamErrorDomainSSL and as per CFStream doc error code belonging to this domain can be found in SecureTransport.h file. As per this file -9824 is

errSSLPeerHandshakeFail     = -9824,    /* handshake failure */

Solution is to obtain a certificate from a known certificate authority or add that certificate to the trusted list of certificates in your keychain.

Whenever you try to connect to site with untrusted certificate following API is invoked to make a decision about this untrusted certificate. You most probably need to implement this NSURLConnectionDelegate method

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

Inside this method you can call following to investigate about certificates.

SecTrustRef trust = [[challenge protectionSpace] serverTrust];
SecCertificateRef leafCert = SecTrustGetCertificateAtIndex(trust, 0);