The CertCreateCertificateContext 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.
PCCERT_CONTEXT CertCreateCertificateContext( DWORD dwCertEncodingType, const BYTE *pbCertEncoded, DWORD cbCertEncoded );
Specifies the type of encoding 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:
A pointer to a buffer that contains the encoded certificate from which the context is to be created.
The size, in bytes, of the pbCertEncoded buffer.
||A certificate encoding type that is not valid was specified. Currently, only the X509_ASN_ENCODING type is supported.|
The CERT_CONTEXT must be freed by calling CertFreeCertificateContext. CertDuplicateCertificateContext can be called to make a duplicate. CertSetCertificateContextProperty and CertGetCertificateContextProperty can be called to store and read properties for the certificate.
The following example shows creating a certificate context from an encoded certificate. The created context is not put in a certificate store. For another example that uses this function, see Example C Program: Certificate Store Operations.
#include <windows.h> #include <stdio.h> #include <Wincrypt.h>
|Windows version||Windows XP [desktop apps||UWP apps] Windows Server 2003 [desktop apps||UWP apps]|