(C++) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.Note: This example requires Chilkat v10.1.2 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";
CkCert cert;
int i = 0;
while (i < numCerts) {
certStore.GetCert(i,cert);
std::cout << cert.subjectDN() << "\r\n";
std::cout << cert.subjectCN() << "\r\n";
std::cout << cert.serialNumber() << "\r\n";
std::cout << "----" << "\r\n";
i = i + 1;
}
certStore.CloseCertStore();
}
|