我试图在我的iOS应用程序中使用一个自签名证书iOS。我遵循了这个很好的教程:http://initwithfunk.com/blog/2014/03/12/afnetworking-ssl-pinning-with-self-signed-certificates/
我在项目中添加了我的.cer文件。在我的AFHTTPRequestOperationManager中:
self.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
self.securityPolicy.allowInvalidCertificates = YES;
但我总是看到-1012错误:
错误操作无法完成。(NSURLErrorDomain错误-1012.)
我检查了+ (NSArray *)defaultPinnedCertificates
,它正确地加载了我的.cer
。
但是evaluateServerTrust:forDomain:
总是返回NO:
return trustedCertificateCount == [serverCertificates count];
[serverCertificates count]
=2,trustedCertificateCount
= 1。
这意味着什么?你能帮帮我吗?
发布于 2014-07-22 12:14:06
AFSecurityPolicy
的默认行为是验证证书链。您应该添加所有中间证书,或者禁用该链的验证:
self.securityPolicy.validatesCertificateChain = NO;
添加中间证书是首选方法。
https://stackoverflow.com/questions/24882276
复制相似问题