case AFSSLPinningModeCertificate: {
NSMutableArray *pinnedCertificates = [NSMutableArray array];
for (NSData *certificateData in self.pinnedCertificates) {
[pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)];
}
SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates);
if (!AFServerTrustIsValid(serverTrust)) {
return NO;
}
if (!self.validatesCertificateChain) {
return YES;
}
NSUInteger trustedCertificateCount = 0;
for (NSData *trustChainCertificate in serverCertificates) {
if ([self.pinnedCertificates containsObject:trustChainCertificate]) {
trustedCertificateCount++;
}
}
return trustedCertificateCount == [serverCertificates count];
}
在AFSecurityPolicy.m 中,SecCertificateCreateWithData 返回空值((__bridge CFDataRef)certificateData 可以拿到NSBundle存放的.cer证书),导致程序崩溃.
是因为证书出了问题吗?
http://www.cocoachina.com/bbs...
同求,難道就沒有其他人遇到 嗎,
剛好今天也遇到這個問題解決了返回空是因為服務端給你的是經過base64加密的證書iOS 用戶端需要解密成明文的證書具體方法看鏈接http://www.jianshu.com/p/ 7446...