I’m trying to use a key I got from a pfx.
CRYPT_DATA_BLOB cdb = {};
cdb.cbData = ...; // blob of a PFX
cdb.pbData = ...;
auto store = PFXImportCertStore(&cdb, L"12345678", PKCS12_NO_PERSIST_KEY | CRYPT_EXPORTABLE | PKCS12_ALLOW_OVERWRITE_KEY | PKCS12_INCLUDE_EXTENDED_PROPERTIES);
auto ctx = CertEnumCertificatesInStore(store, 0);
HCRYPTPROV_OR_NCRYPT_KEY_HANDLE k = 0;
DWORD ks = 0;
BOOL r = 0;
CryptAcquireCertificatePrivateKey(ctx, 0, 0, &k,&ks,&r);
0x8009200b : Cannot find the certificate and private key for decryption
. I ‘ve tried also other flags in PFXImportCertStore, the private key can’t be found.
Moreover, the certificate can’t be later used in AcquireCredentialsHandle(), with the same error.
Why it can’t find the private key where it successfully imports it from the pfx blob?