'kCFStreamSSLAllowsExpiredCertificates'和'kCFStreamSSLAllowsAnyRoot'已弃用 [英] 'kCFStreamSSLAllowsExpiredCertificates' and 'kCFStreamSSLAllowsAnyRoot' is deprecated
问题描述
我已将ASIHTTPRequest库添加到我的应用中。现在,我正在尝试删除项目中的所有警告。我修复了除ASIHTTPRequest之外的所有其他警告。我收到以下警告。
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'已被弃用:
'kCFStreamSSLAllowsExpiredCertificates' is deprecated:
'kCFStreamSSLAllowsAnyRoot'已被弃用:
'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中的注释:
As per the comments in CFSocketStream.h in the CFNetwork framework:
kCFStreamSSLAllowsExpiredCertificates:
kCFStreamSSLAllowsExpiredRoots:
kCFStreamSSLAllowsAnyRoot:
kCFStreamSSLAllowsExpiredCertificates:
kCFStreamSSLAllowsExpiredRoots:
kCFStreamSSLAllowsAnyRoot:
不推荐使用影响不受信任的证书链评估的SSL握手标志。相反,使用单个属性 kCFStreamSSLValidatesCertificateChain
来禁用证书链检查,如果用户已确定这样做是合适的
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
因此,简单的解决方案是删除已弃用的密钥及其值。在<$ c中仅保留 kCFStreamSSLValidatesCertificateChain
和 kCFStreamSSLPeerName
$ c> sslProperties 字典。
So the simple solution is to remove the deprecated keys and their values. Keep only kCFStreamSSLValidatesCertificateChain
and kCFStreamSSLPeerName
in the sslProperties
dictionary.
这篇关于'kCFStreamSSLAllowsExpiredCertificates'和'kCFStreamSSLAllowsAnyRoot'已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!