Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

C++
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900