ios – ‘kCFStreamSSLAllowsExpiredCertificates’和’kCFStreamSSLAllowsAnyRoot’已被弃用

我已经在我的应用程序中添加了“ASIHTTPRequest”库.现在,我试图删除我的项目中的所有警告.除了“ASIHTTPRequest”之外,我已经修复了所有其他警告.我在下面发出警告.

kcfStreamSSLAllowsExpiredCertificates’ is deprecated:

kcfStreamSSLAllowsAnyRoot’ is deprecated:

如何解决这个问题?

码:

NSDictionary *sslProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
                      [NSNumber numberWithBool:YES],kcfStreamSSLAllowsExpiredCertificates,[NSNumber numberWithBool:YES],kcfStreamSSLAllowsAnyRoot,[NSNumber numberWithBool:NO],kcfStreamSSLValidatesCertificateChain,kcfNull,kcfStreamSSLPeerName,nil];

解决方法

根据CFNetwork框架中的CFSocketStream.h中的注释:

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

因此,简单的解决方案是删除不推荐使用的键及其值.在sslProperties字典中只保留kcfStreamSSLValidatesCertificateChain和kcfStreamSSLPeerName.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...