TrustKit和AFNetworking之间的集成

时间:2018-04-12 13:03:33

标签: ios objective-c afnetworking afnetworking-3 certificate-pinning

是否可以将TrustKit(https://github.com/datatheorem/TrustKit)与AFNetworking集成?对IOS的任何建议? 谢谢!

1 个答案:

答案 0 :(得分:1)

[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition(NSURLSession * _Nonnull session, NSURLAuthenticationChallenge * _Nonnull challenge, NSURLCredential *__autoreleasing  _Nullable * _Nullable credential) {
    __block NSURLSessionAuthChallengeDisposition dispositionToReturn = NSURLSessionAuthChallengePerformDefaultHandling;
    if (![TrustKit.sharedInstance.pinningValidator handleChallenge:challenge completionHandler:^(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential * _Nullable credential) {
        dispositionToReturn = disposition;
    }]){
        return NSURLSessionAuthChallengePerformDefaultHandling;
    }
    return dispositionToReturn;
}];