(Unicode C++) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.Note: This example requires Chilkat v10.1.2 or greater.
#include <CkCertStoreW.h>
#include <CkCertW.h>
void ChilkatSample(void)
{
CkCertStoreW 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) {
wprintf(L"%s\n",certStore.lastErrorText());
return;
}
int numCerts = certStore.get_NumCertificates();
wprintf(L"numCerts = %d\n",numCerts);
CkCertW cert;
int i = 0;
while (i < numCerts) {
certStore.GetCert(i,cert);
wprintf(L"%s\n",cert.subjectDN());
wprintf(L"%s\n",cert.subjectCN());
wprintf(L"%s\n",cert.serialNumber());
wprintf(L"----\n");
i = i + 1;
}
certStore.CloseCertStore();
}
|