(Unicode C++) Apple Keychain - List Certificates
Iterates over the certificates in the Apple Keychain.
Note: This example requires Chilkat v10.0.0 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);
int i = 0;
while (i < numCerts) {
CkCertW *cert = certStore.GetCertificate(i);
wprintf(L"%s\n",cert->subjectDN());
wprintf(L"%s\n",cert->subjectCN());
wprintf(L"%s\n",cert->serialNumber());
wprintf(L"----\n");
delete cert;
i = i + 1;
}
certStore.CloseCertStore();
}
|