(Objective-C) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.
Note: This example requires Chilkat v10.0.0 or greater.
#import <CkoCertStore.h>
#import <CkoCert.h>
CkoCertStore *certStore = [[CkoCertStore alloc] init];
// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
BOOL success = [certStore OpenCurrentUserStore: NO];
if (success == NO) {
NSLog(@"%@",certStore.LastErrorText);
return;
}
int numCerts = [certStore.NumCertificates intValue];
NSLog(@"%@%d",@"numCerts = ",numCerts);
int i = 0;
while (i < numCerts) {
CkoCert *cert = [certStore GetCertificate: [NSNumber numberWithInt: i]];
NSLog(@"%@",cert.SubjectDN);
NSLog(@"%@",cert.SubjectCN);
NSLog(@"%@",cert.SerialNumber);
NSLog(@"%@",@"----");
i = i + 1;
}
[certStore CloseCertStore];
|