Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function creates a certificate context from an encoded certificate. The created context is not persisted to a certificate store. The function makes a copy of the encoded certificate within the created context.

Syntax

PCCERT_CONTEXT WINAPI CertCreateCertificateContext(
  DWORD 
dwCertEncodingType,
  const BYTE* 
pbCertEncoded,
  DWORD 
cbCertEncoded
);

Parameters

dwCertEncodingType

[in] Specifies the type of encoding used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.

pbCertEncoded

[in] Pointer to a buffer containing the encoded certificate from which the context is to be created.

cbCertEncoded

[in] Size, in bytes, of the pbCertEncodedbuffer.

Return Value

If the function succeeds, the return value is a pointer to a read-only CERT_CONTEXTstructure.

If the function is unable to decode and create the certificate context, the return value is NULL.

For extended error information, call the GetLastErrorfunction.

The GetLastErrorfunction can return E_INVALIDARG, which mean that an invalid certificate encoding type was specified. Currently, only the X509_ASN_ENCODING type is supported.

Remarks

The CERT_CONTEXTstructure must be freed by calling the CertFreeCertificateContextfunction. The CertDuplicateCertificateContextfunction can be called to make a duplicate. The CertSetCertificateContextPropertyand CertGetCertificateContextPropertyfunctions can be called to store and read properties for the certificate.

The desktop operating system supports the flag PKCS_7_ASN_ENCODING, but Windows Embedded CE does not and ignores the flag when it is specified.

Requirements

Header wincrypt.h
Library crypt32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also