要解决 AFNetworking 的 SSL pinning 不起作用的问题,可以按照以下步骤进行:
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"YourCertificate" ofType:@"cer"];
NSData *certData = [NSData dataWithContentsOfFile:cerPath];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
securityPolicy.pinnedCertificates = @[certData];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.securityPolicy = securityPolicy; // 设置使用 SSL pinning 的 securityPolicy
[[NSURLCache sharedURLCache] removeAllCachedResponses];
希望以上解决方法能够帮助你解决 AFNetworking 的 SSL pinning 不起作用的问题。