Confirm Self-Signed Certificate Using AFNetworking

I want to connect my iOS application with AFNetwork to my web server with a self-signed certificate. I found a solution on github ( https://github.com/AFNetworking/AFNetworking/pull/694 ) I tried this, and certificate bonding seems to work, but I got another error:

Domain Error = NSURLErrorDomain Code = -1012 "Operation could not be completed. (NSURLErrorDomain error -1012.)" UserInfo = 0x7bc2090 {NSErrorFailingURLKey = (my domain)}

Does anyone know if this error is related to AFNetworking Framework and self-signed certificate or not?

Solved: I found a solution for the error. I had to set SSLPinningMode to AFSSLPinningModeCertificate, now it works.

AFJSONRequestOperation *operation =[AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSDictionary *resDictionary = (NSDictionary *)JSON; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"%@",error); }]; operation.SSLPinningMode = AFSSLPinningModeCertificate; [operation start]; 
+4
source share
1 answer

Try this job.

 AFJSONRequestOperation *operation =[AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) { NSDictionary *resDictionary = (NSDictionary *)JSON; } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) { NSLog(@"%@",error); }]; operation.securityPolicy.allowInvalidCertificates = YES; [operation start]; 
0
source

All Articles