美文网首页
https验证的代码块

https验证的代码块

作者: Archer_S | 来源:发表于2017-03-30 17:51 被阅读11次

    没错,博主又来写防忘文了,直接贴上一段https验证的代码

    + (AFSecurityPolicy*)customSecurityPolicy {
        AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
        NSData *certData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"XXXXHttps" ofType:@"cer"]];
        NSSet *cerSet  = [NSSet setWithObject:certData];
        securityPolicy.allowInvalidCertificates = YES;
        [securityPolicy setValidatesDomainName:NO];
        if(certData){
            [securityPolicy setPinnedCertificates:cerSet];
        }
        return securityPolicy;
    }
    

    博主还在学习......未完待续......

    相关文章

      网友评论

          本文标题:https验证的代码块

          本文链接:https://www.haomeiwen.com/subject/znepottx.html