I have a pkcs#7 file with included signers certificate, CA certificate, CRL. Now, to verify signature from this file I get the certificate from it. I try to do:
HANDLE hFile;
if(!(hFile = CreateFile(L"c:\\users\\timur\\desktop\\sign_pkcs7.sig",
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL)))
{
printf("Error opening file %d\n", GetLastError());
}
HCERTSTORE hPkcsStore = 0;
if(!(hPkcsStore = CertOpenStore(
CERT_STORE_PROV_PKCS7,
MY_TYPE,
NULL,
CERT_STORE_OPEN_EXISTING_FLAG,
hFile)))
{
printf("Cert not found in pkcs7 store error %d.\n",GetLastError());
}
But while calling CertOpenStore program fails with Access violation reading location 0x0000001c.
You can use CryptQueryObject to open the P7B file or files in many other formats (the code will be the same as here).
User contributions licensed under CC BY-SA 3.0