CertGetCTLContextProperty

The CertGetCTLContextProperty function gets a property for the specified CTL context.

#include <wincrypt.h>
BOOL WINAPI CertGetCTLContextProperty(
  PCCTL_CONTEXT pCtlContext,   // in
  DWORD dwPropId,              // in
  void *pvData,                // out
  DWORD *pcbData               // in/out
);
 

Parameters

pCtlContext
Pointer to the CTL context.
dwPropId
ID for the desired property.

See CertGetCertificateContextProperty for a complete list of property IDs. CERT_SHA1_HASH_PROP_ID or CERT_NEXT_UPDATE_LOCATION_PROP_ID are the predefined properties of most interest.

pvData
Pointer to a buffer that receives the data as indicated by dwPropId. Elements pointed to by fields in the pvData structure follow the structure. Therefore, the size contained in pcbData may exceed the size of the structure.

This parameter can be NULL to set the size of this information for memory allocation purposes. For more information, see Common In/Out Parameter Conventions.

pcbData
Pointer to a variable that specifies the size, in bytes, of the buffer pointed to by the pvData parameter. When the function returns, the variable pointed to by the pcbData parameter contains the number of bytes stored in the buffer. This parameter can be NULL, only if pvData is NULL.

Note  When processing the data returned in the buffer, applications need to use the actual size of the data returned. The actual size may be slightly smaller than the size of the buffer specified on input. (On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer.) On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.

Return Values

TRUE if the function succeeded. FALSE if the function failed.

Call GetLastError to see the reason for any failures. Note that errors from the called function CryptHashCertificate may be propagated to this function. This function has the following error codes:

Error code Description
ERROR_MORE_DATA If the buffer specified by the pvData parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code, and stores the required buffer size, in bytes, into the variable pointed to by pcbData.
CRYPT_E_NOT_FOUND The CTL doesn't have the specified property.

Example

See the example for CertEnumCertificateContextProperties, and extrapolate from a certificate to a CTL ( PCCERT_CONTEXT becomes PCCTL_CONTEXT, pCertContext becomes pCTLContext, CertEnumCertificateContextProperties becomes CertEnumCTLContextProperties, and CertGetCertificateContextProperty becomes CertGetCTLContextProperty).

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

CertEnumCTLContextProperties, CertSetCTLContextProperty