I wanna do SSL pinning for my app with AFNetworking. Below is my code.
NSString *certificatePath = [[NSBundle mainBundle] pathForResource:@"fileName" ofType:@"crt"];
NSData *data = [NSData dataWithContentsOfFile:certificatePath];
NSSet *set = [NSSet setWithObjects:data, nil];
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
[securityPolicy setValidatesDomainName:NO];
[securityPolicy setAllowInvalidCertificates:YES];
[securityPolicy setPinnedCertificates:set];
requestManager.securityPolicy = securityPolicy;
But app is crashing with above code with this error *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
When I change the pinning mode to AFSSLPinningModePublicKey, its crashing with different error "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “Domain name” which could put your confidential information at risk." Not sure what could be the issue.