(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 <C_CkCertStoreW.h>
#include <C_CkCertW.h>
void ChilkatSample(void)
{
HCkCertStoreW certStore;
BOOL success;
int numCerts;
int i;
HCkCertW cert;
certStore = CkCertStoreW_Create();
// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
success = CkCertStoreW_OpenCurrentUserStore(certStore,FALSE);
if (success == FALSE) {
wprintf(L"%s\n",CkCertStoreW_lastErrorText(certStore));
CkCertStoreW_Dispose(certStore);
return;
}
numCerts = CkCertStoreW_getNumCertificates(certStore);
wprintf(L"numCerts = %d\n",numCerts);
i = 0;
while (i < numCerts) {
cert = CkCertStoreW_GetCertificate(certStore,i);
wprintf(L"%s\n",CkCertW_subjectDN(cert));
CkCertW_Dispose(cert);
i = i + 1;
}
CkCertStoreW_CloseCertStore(certStore);
CkCertStoreW_Dispose(certStore);
}
|