Click here to Skip to main content
14,427,558 members
Rate this:
Please Sign up or sign in to vote.
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;
            } // if

iResult = PKCS12_parse(p12, "mqroot", &pkey, &cert, NULL);
            if ( !iResult )
            {
                hResult = GetLastError();
                __leave;
            } // if


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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100