Here's how it can be doen:
NSString* certPath = [[NSBundle mainBundle] pathForResource:@"myCertificate" ofType:@"cer"]; NSData* certData = [NSData dataWithContentsOfFile:certPath]; SecCertificateRef cert; if( [certData length] ) { cert = SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certData); if( cert != NULL ) { CFStringRef certSummary = SecCertificateCopySubjectSummary(cert); NSString* summaryString = [[NSString alloc] initWithString:(__bridge NSString*)certSummary]; NSLog(@"CERT SUMMARY: %@", summaryString); CFRelease(certSummary); } else { NSLog(@" *** ERROR *** trying to create the SSL certificate from data located at %@, but failed", certPath); } }
myCertificate.cer should be in your application. I am creating a cer file using openssl. If you plan to use this in your iOS app, make sure your certificate contains the necessary extensions, check here . Even though the answer is -1, it helped me achieve this.
source share