Question:
Here is the code :
CkCreateCS ccs;
ccs.put_ReadOnly(true);
// Open the local machine store:
CkCertStore *cs = 0;
cs = ccs.OpenRegistryStore("localMachine","SOFTWARE/Microsoft/SystemCertificates/AuthRoot/Certificates");
if (!(cs == 0 )) {
CkCert *cert = 0;
long numCerts;
numCerts = cs->get_NumCertificates();
long i;
// Print the distinguished name of each certificate
for (i = 0; i <= numCerts - 1; i++) {
cert = cs->GetCertificate(i);
TRACE("%s\n",cert->subjectDN());
TRACE("%s\n",cert->subjectO());
delete cert;
}
delete cs;
}
else {
TRACE("%s\n",ccs.lastErrorText());
}
ccs.OpenRegistryStore return true but get_NumCertificates return 0 although I have a lot of certificates I can see through regedit/certmsg.msc.
Where is the problem in this source code ?
Thank you for your help.
When running certmgr.msc, the certificate stores you will see are for CurrentUser (not LocalMachine). You would need to start the certmgr.msc in a very specific way to see the LocalMachine cert stores.
Try passing "CurrentUser" instead of "localMachine" to OpenRegistryStore.
CurrentUser or LocalMachine : same problem : Always 0. This code works for you ? Did you test it ?