Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'kCFStreamSSLAllowsExpiredCertificates' and 'kCFStreamSSLAllowsAnyRoot' is deprecated

I have added the "ASIHTTPRequest" library to my app. Now, I'm trying to remove all warnings in my project. I have fixed all other warnings except those for "ASIHTTPRequest". I'm getting the warnings below.

'kCFStreamSSLAllowsExpiredCertificates' is deprecated:

'kCFStreamSSLAllowsAnyRoot' is deprecated:

How to resolve this?

Code:

NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                      [NSNumber numberWithBool:YES], kCFStreamSSLAllowsExpiredCertificates,
                      [NSNumber numberWithBool:YES], kCFStreamSSLAllowsAnyRoot,
                      [NSNumber numberWithBool:NO],  kCFStreamSSLValidatesCertificateChain,
                      kCFNull,kCFStreamSSLPeerName,
                      nil];

screenshot

like image 357
2vision2 Avatar asked Nov 11 '14 12:11

2vision2


2 Answers

As per the comments in CFSocketStream.h in the CFNetwork framework:

kCFStreamSSLAllowsExpiredCertificates:
kCFStreamSSLAllowsExpiredRoots:
kCFStreamSSLAllowsAnyRoot:

The SSL handshake flags which affect untrusted certificate chain evaluation are deprecated. Instead, use the single property kCFStreamSSLValidatesCertificateChain to disable certificate chain checking if the user has decided that it is appropriate to do so

So the simple solution is to remove the deprecated keys and their values. Keep only kCFStreamSSLValidatesCertificateChain and kCFStreamSSLPeerName in the sslProperties dictionary.

like image 126
Priya Avatar answered Oct 10 '22 00:10

Priya


Add the following line above your declaration:

#pragma clang diagnostic ignored "-Wdeprecated-declarations"
like image 37
machinehead115 Avatar answered Oct 10 '22 01:10

machinehead115