(C++) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.
Note: This example requires Chilkat v10.0.0 or greater.
#include <CkCertStore.h>
#include <CkCert.h>
void ChilkatSample(void)
{
CkCertStore certStore;
// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
bool success = certStore.OpenCurrentUserStore(false);
if (success == false) {
std::cout << certStore.lastErrorText() << "\r\n";
return;
}
int numCerts = certStore.get_NumCertificates();
std::cout << "numCerts = " << numCerts << "\r\n";
int i = 0;
while (i < numCerts) {
CkCert *cert = certStore.GetCertificate(i);
std::cout << cert->subjectDN() << "\r\n";
std::cout << cert->subjectCN() << "\r\n";
std::cout << cert->serialNumber() << "\r\n";
std::cout << "----" << "\r\n";
delete cert;
i = i + 1;
}
certStore.CloseCertStore();
}
|