共用方式為


CertCreateCertificateContext

A version of this page is also available for

Windows Embedded CE 6.0 R3

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 pbCertEncoded buffer.

Return Value

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

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

For extended error information, call the GetLastError function.

The GetLastError function 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_CONTEXT structure must be freed by calling the CertFreeCertificateContext function. The CertDuplicateCertificateContext function can be called to make a duplicate. The CertSetCertificateContextProperty and CertGetCertificateContextProperty functions 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

Reference

CertDuplicateCertificateContext
CertFreeCertificateContext
CertGetCertificateContextProperty
CertSetCertificateContextProperty
CERT_CONTEXT