zoukankan      html  css  js  c++  java
  • iOS https 证书链获取

    - (void)URLSession:(NSURLSession *)session

    didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge

     completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler

    {

    if ([self.securityPolicy evaluateServerTrust:challenge.protectionSpace.serverTrust forDomain:challenge.protectionSpace.host])

    }

    - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust

                      forDomain:(NSString *)domain

    {

    NSArray *serverCertificates = AFCertificateTrustChainForServerTrust(serverTrust);

    }

    static NSArray * AFCertificateTrustChainForServerTrust(SecTrustRef serverTrust) {

        CFIndex certificateCount = SecTrustGetCertificateCount(serverTrust);

        NSMutableArray *trustChain = [NSMutableArray arrayWithCapacity:(NSUInteger)certificateCount];

        for (CFIndex i = 0; i < certificateCount; i++) {

            SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, i);

            [trustChain addObject:(__bridge_transfer NSData *)SecCertificateCopyData(certificate)];

        }

        return [NSArray arrayWithArray:trustChain];

    }

  • 相关阅读:
    Map集合
    Collection的另外一个子类LinkedList&Set集合
    多项式牛顿迭代 学习笔记
    《混凝土数学》第二章 和式 学习笔记
    洛谷P5039 最小生成树 题解
    gdfzoj#236 | 提高组练习题16 Set
    CF979E 题解
    CF1039D 题解
    CF886E 题解
    CF1061C 题解
  • 原文地址:https://www.cnblogs.com/feng9exe/p/8067434.html
Copyright © 2011-2022 走看看