(Objective-C) Iterate over Certificates in a Certificate Store
Demonstrates how to iterate over the certificates in a certificate store.
Note: Requires Chilkat v10.1.2 or later.
#import <CkoCertStore.h>
#import <CkoCert.h>
CkoCertStore *certStore = [[CkoCertStore alloc] init];
// This opens the Current User certificate store on Windows,
// On MacOS and iOS it opens the default Keychain.
BOOL readOnly = NO;
BOOL success = [certStore OpenCurrentUserStore: readOnly];
if (success == NO) {
NSLog(@"%@",certStore.LastErrorText);
return;
}
CkoCert *cert = [[CkoCert alloc] init];
int numCerts = [certStore.NumCertificates intValue];
int i = 0;
while (i < numCerts) {
// Load the cert object with the Nth certificate.
[certStore GetCert: [NSNumber numberWithInt: i] cert: cert];
NSLog(@"%d%@%@",i,@": ",cert.SubjectCN);
i = i + 1;
}
|