0

I've been trying to use Alamofire to pin a PEM certificate using these methods:

I've also tried using AFNetworking:

NSData *certificateData = [NSData dataWithContentsOfFile:certificatePath];
SecCertificateRef cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) certificateData);
NSArray *arr = [[NSArray alloc] initWithObjects:(__bridge_transfer NSData *)SecCertificateCopyData(cert), nil];
[securityPolicy setPinnedCertificates:arr];

Most of the time I will get -999 and -1012 errors. When running a curl command, it works as it should. However, it does not seem to work when converting the PEM certificate to a DER format.

muru
  • 4,723
  • 1
  • 34
  • 78
sonics876
  • 947
  • 2
  • 13
  • 31
  • Hi could you please give me some more details to understand. The code is in objective c, do you want to have it in swift or objective c. – maheswaran Apr 04 '19 at 10:32
  • Try this https://stackoverflow.com/questions/34223291/ios-certificate-pinning-with-swift-and-nsurlsession/34223292 – maheswaran Apr 04 '19 at 18:49

0 Answers0