Created memory store with desired certificate moved from system store to memory store and saved that store to file.
The moved certificate can be acquired by using the function
CertFindCertificateInStore() from the created memory store successfully.
The memory store is exported successfully using the function
bResult = PFXExportCertStoreEx(
hMemoryStore,
&pPFX,
wszPassword,
NULL,
EXPORT_PRIVATE_KEYS |
REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY |
REPORT_NO_PRIVATE_KEY );
BIO* input = BIO_new_mem_buf((void*)pPFX.pbData, pPFX.cbData);
p12 = d2i_PKCS12_bio(input, NULL);
if(NULL == p12)
{
hResult = GetLastError();
__leave;
}
iResult = PKCS12_parse(p12, "mqroot", &pkey, &cert, NULL);
if ( !iResult )
{
hResult = GetLastError();
__leave;
}
Here when the certificate is parsed returning 1, but the pkey and cert parameters are NULL. What can be the reason for getting private key and certificate as NULL.