suchen

Heim  >  Fragen und Antworten  >  Hauptteil

ios - AFNetWorking Https SecCertificateCreateWithData 返回nil

        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证书),导致程序崩溃.
是因为证书出了问题吗?

伊谢尔伦伊谢尔伦2772 Tage vor633

Antworte allen(3)Ich werde antworten

  • 高洛峰

    高洛峰2017-04-17 17:55:05

    http://www.cocoachina.com/bbs...

    Antwort
    0
  • 迷茫

    迷茫2017-04-17 17:55:05

    同求,难道就没有其他人遇到 吗,

    Antwort
    0
  • 黄舟

    黄舟2017-04-17 17:55:05

    正好今天也遇到这个问题 解决了 返回空 是因为 服务端给你的是经过base64加密的证书 iOS 客户端需要 解密成明文的证书 具体方法 看链接 http://www.jianshu.com/p/7446...

    Antwort
    0
  • StornierenAntwort