在AFNetworking中,如果使用SSL固定(SSL pinning)时遇到崩溃问题,可以尝试以下解决方法:
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"YourSSL" ofType:@"cer"];
NSData *certData = [NSData dataWithContentsOfFile:cerPath];
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
securityPolicy.pinnedCertificates = @[certData];
manager.securityPolicy = securityPolicy;
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.securityPolicy.allowInvalidCertificates = YES;
manager.securityPolicy.validatesDomainName = NO;
需要注意的是,忽略证书验证会导致网络请求不再安全,可能会受到中间人攻击。
希望这些解决方法可以帮助你解决AFNetworking中的SSL固定与崩溃问题。