I'm trying to enable SSL Pinning on the example project but I get the following response error whenever I try it:
Error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo=0x991daf0 {NSErrorFailingURLKey=https://alpha-api.app.net/stream/0/posts/stream/global, NSErrorFailingURLStringKey=https://alpha-api.app.net/stream/0/posts/stream/global, NSLocalizedDescription=cancelled}
I'm adding the following method to AFAppDotNetAPIClient.m:
- (instancetype)initWithBaseURL:(NSURL *)url
{
self = [super initWithBaseURL:url];
if (!self) return nil;
self.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModePublicKey];
return self;
}
I've been trying the same procedure in a personal project with it's own certificate in DER format but I get the same error.
Any ideas? Thank you!
I'm having a bunch of issues with certificate verifications with 2.0 too but I get the error code -1012
@FredericJacobs I get the same error code when using AFHTTPRequestOperation directly instead of AFURLSessionManager. I think the source of the problem, be it AFNetworking itself or a misunderstanding of us, is the same.
I see the issue. It looks like defaultPinnedCertificates isn't actually being set anywhere...
You can get around now this for now by explicitly setting the pinned certificate array with the NSData of your certificate file.
The default behavior should probably be to at least set the default pinned certificates by default in the policyWithPinningMode: method.
Submitting a PR for this in a bit.
Thank you for your temporary solution and for the pull request @kcharwood :-)
help me !!!!
Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo=0x78fc41e0 {NSErrorFailingURLKey=myURL, NSErrorFailingURLStringKey=myURL, NSLocalizedDescription=cancelled}
Most helpful comment
help me !!!!
Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo=0x78fc41e0 {NSErrorFailingURLKey=myURL, NSErrorFailingURLStringKey=myURL, NSLocalizedDescription=cancelled}