Skip to content

Latest commit

 

History

History
207 lines (155 loc) · 7.28 KB

nf-wincrypt-certcreatecontext.md

File metadata and controls

207 lines (155 loc) · 7.28 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:wincrypt.CertCreateContext
CertCreateContext function (wincrypt.h)
Creates the specified context from the encoded bytes. The context created does not include any extended properties.
CERT_CREATE_CONTEXT_NOCOPY_FLAG
CERT_CREATE_CONTEXT_NO_ENTRY_FLAG
CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG
CERT_CREATE_CONTEXT_SORTED_FLAG
CERT_STORE_CERTIFICATE_CONTEXT
CERT_STORE_CRL_CONTEXT
CERT_STORE_CTL_CONTEXT
CertCreateContext
CertCreateContext function [Security]
_crypto2_certcreatecontext
security.certcreatecontext
wincrypt/CertCreateContext
security\certcreatecontext.htm
security
0911054b-a47a-4046-b121-a236fc4b018b
12/05/2018
CERT_CREATE_CONTEXT_NOCOPY_FLAG, CERT_CREATE_CONTEXT_NO_ENTRY_FLAG, CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG, CERT_CREATE_CONTEXT_SORTED_FLAG, CERT_STORE_CERTIFICATE_CONTEXT, CERT_STORE_CRL_CONTEXT, CERT_STORE_CTL_CONTEXT, CertCreateContext, CertCreateContext function [Security], _crypto2_certcreatecontext, security.certcreatecontext, wincrypt/CertCreateContext
wincrypt.h
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Crypt32.lib
Crypt32.dll
Windows
19H1
CertCreateContext
wincrypt/CertCreateContext
c++
APIRef
kbSyntax
DllExport
Crypt32.dll
CertCreateContext

CertCreateContext function

-description

The CertCreateContext function creates the specified context from the encoded bytes. The context created does not include any extended properties.

-parameters

-param dwContextType [in]

Specifies the contexts that can be created. For example, to create a certificate context, set dwContextType to CERT_STORE_CERTIFICATE_CONTEXT.

Currently defined context type flags are shown in the following table.

Value Meaning
CERT_STORE_CERTIFICATE_CONTEXT
Certificate context.
CERT_STORE_CRL_CONTEXT
CRL context.
CERT_STORE_CTL_CONTEXT
CTL context.

-param dwEncodingType [in]

Specifies the encoding type used. Currently, only X509_ASN_ENCODING and PKCS_7_ASN_ENCODING are being used; however, additional encoding types may be added in the future. For either current encoding type, use:

X509_ASN_ENCODING | PKCS_7_ASN_ENCODING.

-param pbEncoded [in]

A pointer to a buffer that contains the existing encoded context content to be copied.

-param cbEncoded [in]

The size, in bytes, of the pbEncoded buffer.

-param dwFlags [in]

The following flag values are defined and can be combined by using a bitwise-OR operation.

Value Meaning
CERT_CREATE_CONTEXT_NOCOPY_FLAG
The created context points directly to the content pointed to by pbEncoded instead of an allocated copy.
CERT_CREATE_CONTEXT_SORTED_FLAG
The function creates a context with sorted entries. Currently, this flag only applies to a CTL context.

For CTLs, the cCTLEntry member of the returned CTL_INFO structure is always zero. CertFindSubjectInSortedCTL and CertEnumSubjectInSortedCTL must be called to find or enumerate the CTL entries.

CERT_CREATE_CONTEXT_NO_HCRYPTMSG_FLAG
By default, when a CTL context is created, a HCRYTPMSG handle to its SignedData message is created. This flag can be set to improve performance by not creating this handle. This flag can only be used when dwContextType is CERT_STORE_CTL_CONTEXT.
CERT_CREATE_CONTEXT_NO_ENTRY_FLAG
By default, when a CTL context is created, its entries are decoded. When this flag is set, the entries are not decoded and performance is improved. This flag can only be used when dwContextType is CERT_STORE_CTL_CONTEXT.

-param pCreatePara [in, optional]

A pointer to a CERT_CREATE_CONTEXT_PARA structure.

If pCreatePara and its pfnFree member are both non-NULL, the pfnFree member is used to free the memory specified by the pvFree member. If the pvFree member is NULL, the pfnFree member is used to free the pbEncoded pointer.

If pCreatePara or its pfnFree member is NULL, no attempt is made to free pbEncoded.

-returns

If the function succeeds, the return value is a pointer to the newly created context. The pvFree member of pCreatePara must be called to free the created context.

If the function fails, the return value is NULL. For extended error information, call GetLastError.

If GetLastError returns ERROR_CANCELLED, this means that the PFN_CERT_CREATE_CONTEXT_SORT_FUNC callback function returned FALSE to stop the sort.

-see-also

CTL_INFO

CertEnumSubjectInSortedCTL

CertFindSubjectInSortedCTL

Certificate and Certificate Store Maintenance Functions