Problems with SSL Pinning and AFNetworking 2.5.0 (NSURLErrorDomain error -1012.)

后端 未结 9 2003
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 20:45

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

相关标签:
9条回答
  • 2020-12-07 21:36

    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

    0 讨论(0)
  • 2020-12-07 21:36

    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];
    
    0 讨论(0)
  • 2020-12-07 21:39

    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.

    0 讨论(0)
提交回复
热议问题