Unicode C
Unicode C
Apple Keychain - List Certificates
See more Apple Keychain Examples
Iterates over the certificates in the Apple Keychain.Chilkat Unicode C Downloads
#include <C_CkCertStoreW.h>
#include <C_CkCertW.h>
void ChilkatSample(void)
{
BOOL success;
HCkCertStoreW certStore;
int numCerts;
HCkCertW cert;
int i;
success = FALSE;
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);
cert = CkCertW_Create();
i = 0;
while (i < numCerts) {
CkCertStoreW_GetCert(certStore,i,cert);
wprintf(L"%s\n",CkCertW_subjectDN(cert));
wprintf(L"%s\n",CkCertW_subjectCN(cert));
wprintf(L"%s\n",CkCertW_serialNumber(cert));
wprintf(L"----\n");
i = i + 1;
}
CkCertStoreW_CloseCertStore(certStore);
CkCertStoreW_Dispose(certStore);
CkCertW_Dispose(cert);
}