CryptGetMessageCertificates function (wincrypt.h)

The CryptGetMessageCertificates function returns the handle of an open certificate store containing the message's certificates and CRLs. This function calls CertOpenStore using provider type CERT_STORE_PROV_PKCS7 as its lpszStoreProvider parameter.

Syntax

HCERTSTORE CryptGetMessageCertificates(
  [in] DWORD             dwMsgAndCertEncodingType,
  [in] HCRYPTPROV_LEGACY hCryptProv,
  [in] DWORD             dwFlags,
  [in] const BYTE        *pbSignedBlob,
  [in] DWORD             cbSignedBlob
);

Parameters

[in] dwMsgAndCertEncodingType

Specifies the encoding type used. It is always acceptable to specify both the certificate and message encoding types by combining them with a bitwise-OR operation as shown in the following example:

X509_ASN_ENCODING | PKCS_7_ASN_ENCODING

Currently defined encoding types are:

  • X509_ASN_ENCODING
  • PKCS_7_ASN_ENCODING

[in] hCryptProv

This parameter is not used and should be set to NULL.

Windows Server 2003 and Windows XP:  Handle of the CSP passed to CertOpenStore. For more information, see CertOpenStore.Unless there is a strong reason for passing a specific cryptographic provider in hCryptProv, pass zero to cause the default RSA or DSS provider to be acquired.

This parameter's data type is HCRYPTPROV.

[in] dwFlags

Flags passed to CertOpenStore. For more information, see CertOpenStore.

[in] pbSignedBlob

A pointer to a buffered CRYPT_INTEGER_BLOB structure that contains the signed message.

[in] cbSignedBlob

The size, in bytes, of the signed message.

Return value

Returns the certificate store containing the message's certificates and CRLs. For an error, NULL is returned.

The following lists the error code most commonly returned by the GetLastError function.

Return code Description
E_INVALIDARG
Invalid message and certificate encoding types. Currently only PKCS_7_ASN_ENCODING and X509_ASN_ENCODING are supported.
 

If the function fails, GetLastError may return an Abstract Syntax Notation One (ASN.1) encoding/decoding error. For information about these errors, see ASN.1 Encoding/Decoding Return Values.

Remarks

Use GetLastError to determine the reason for any errors.

Examples

For an example that uses this function, see Example C Program: Setting and Getting Certificate Store Properties.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See also

CryptVerifyMessageSignature

Simplified Message Functions