(Objective-C) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
#import <CkoCertStore.h>
#import <NSString.h>
#import <CkoCert.h>
CkoCertStore *certStore = [[CkoCertStore alloc] init];
BOOL success;
NSString *pfxPath = @"/Users/chilkat/testData/pfx/chilkat_ssl.pfx";
NSString *pfxPassword = @"test";
success = [certStore LoadPfxFile: pfxPath password: pfxPassword];
if (success != YES) {
NSLog(@"%@",certStore.LastErrorText);
return;
}
int numCerts = [certStore.NumCertificates intValue];
NSLog(@"%@%d%@",@"PFX contains ",numCerts,@" certificates");
int i = 0;
while (i < numCerts) {
CkoCert *cert = [certStore GetCertificate: [NSNumber numberWithInt: i]];
NSLog(@"%d%@%@",i,@": (Common Name) ",cert.SubjectCN);
NSLog(@"%d%@%@",i,@": (Serial Number) ",cert.SerialNumber);
NSLog(@"%d%@%@",i,@": (Distinguished Name) ",cert.SubjectDN);
i = i + 1;
}
|