We’ve been having a hard time securing our app’s network connections with SSL using AFNetworking 2.5.0.
We use a self-signed certificate authority and implemented a
since you have manager initialized, you can do:
manager.securityPolicy.allowInvalidCertificates = YES;
manager.securityPolicy.validatesDomainName = NO;
and it will work for a self-signed certificate
You're creating an AFSecurityPolicy
with SSLPinningMode
mode AFSSLPinningModeNone
.
For AFNetworking to trust the server, with pinning mode set to AFSSLPinningModeNone
, you must set allowInvalidCertificates
to YES
, but this is the opposite of what you are trying to achieve.
Instead, you should create your security policy with pinning mode AFSSLPinningModeCertificate
or AFSSLPinningModePublicKey
:
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeCertificate];
For me, I had use_frameworks!
set in my Podfile
- the project doesn't make user of Swift and I was using Pods
for AFNetworking
. Commenting this out, fixed the issue for me.