I want to get parent certificate (or all certificates in chain for that matter) from Windows Certificate Store (assuming I know the location of the end certificate). I need to get each one in order to build my own custom X509_STORE
(using OpenSSL).
I think the proper course of action would be:
CertFindCertificateInStore
(done)CertGetCertificateChain
(done)d2i_X509
(done)or
CertFindCertificateInStore
(done)d2i_X509
, go to 2. (done)Then create the store.
The question to answer is then - how to get the parent certificate or all certificates in chain using Windows Certificate Store? I'm probably missing some more or less occult function here.
as the CertFindCertificateInStore
outputs a chain context, one can access it's members using the beautiful construction:
chainContext->rgpChain[0]->rgpElement[iCertIndex]->pCertContext->pbCertEncoded
where iCertIndex
is between 0
(end-certificate) and chainSize -1
(self-signed root certificate).