0

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.

forik
  • 149
  • 4
  • 15

1 Answers1

1

You can use CryptQueryObject to open the P7B file or files in many other formats (the code will be the same as here).

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank You! I'll try it. Now I use functions such as CryptMsgUpdate, CryptMsgGetParam etc.. – forik Mar 05 '12 at 13:06