CertCreateCTLContext

The CertCreateCTLContext function creates a CTL context from an encoded CTL. The created context is not put into a certificate store. It makes a copy of the encoded CTL within the created context.

#include <wincrypt.h>
PCCTL_CONTEXT WINAPI CertCreateCTLContext(
  DWORD dwMsgAndCertEncodingType,          // in
  const BYTE *pbCtlEncoded,                // in
  DWORD cbCtlEncoded                       // in
);
 

Parameters

dwMsgAndCertEncodingType
The type of encoding used. Note that both a certificate and message encoding type is required to be specified 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 shown in the following table.
Encoding type Value
X509_ASN_ENCODING 0x00000001
PKCS_7_ASN_ENCODING 0x00010000

pbCtlEncoded
A pointer to the encoded CTL from which the context is to be created.
cbCtlEncoded
The size, in bytes, of the encoded CTL.

Return Values

If unable to decode and create the CTL_CONTEXT, NULL is returned. Otherwise, a pointer to a read-only CTL_CONTEXT is returned.

Call GetLastError to see the reason for any failures. This function has the following error codes:

Error code Description
E_INVALIDARG Invalid certificate encoding type. Only PKCS_7_ASN_ENCODING and X509_ASN_ENCODING are supported.
CRYPT_E_OSS_ERROR ASN.1 decoding error. Note, to get the OSS error subtract CRYPT_E_OSS_ERROR from the returned error and see asn1code.h for details on the error.

Remarks

The CTL_CONTEXT must be freed by calling CertFreeCTLContext. CertDuplicateCTLContext can be called to make a duplicate. CertSetCTLContextProperty and CertGetCTLContextProperty can be called to store and read properties for the CTL.

Example

See CertCreateCertificateContext. In that example, change all references to "certificate" to "CTL."

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later. Available also in IE 3.02 and later.
  Windows: Requires Windows 95 OSR2 or later.
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use crypt32.lib.

See Also

CertCreateCRLContext, CertCreateCertificateContext