0 Replies - 756 Views - Last Post: 08 December 2015 - 06:36 AM

#1 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 27-March 12

ios AFNetworking using SSL example - pinning (which file to use?)

Posted 08 December 2015 - 06:36 AM

Afternoon all,

I've created a simple app using a webservice and now I want to secure it using a third party SSL. I already have the SSL installed and working on my webservice, now I want my iOS project to connect but I can't figure out how. I've already successfully connected and downloaded to webservice using two different methods just so I can get a decent understanding. NSURLCONNECTION and AFHTTPSESSIONMANAGER. Both work to return the same results.

Now I've been reading different posts on using SSL with those methods. It seems I should install (pin) the public certificate to my app. Below is some code I found to use as a guide. My first question with this is how/where do I get the file to drag into my xcode project. (note I am using Microsoft azure web service)
I went to where I purchased the third party certificate and I can download something there... seems to be two different files... and one is intermediate. Are these the files I am supposed to pin? I also read there is a way to grab them right from my server but I don't know how?

Any ideas?
thanks in advance!

+ (AFSecurityPolicy*)customSecurityPolicy {
AFSecurityPolicy *securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFsslPinningModeNone];
NSString *cerPath = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"der"];
NSData *certData = [NSData dataWithContentsOfFile:cerPath];
[securityPolicy setAllowInvalidCertificates:NO];
[securityPolicy setValidatesCertificateChain:NO];
[securityPolicy setPinnedCertificates:@[certData]];
return securityPolicy;
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1