[This is preliminary documentation and subject to change.]
The CertFindCTLInStore function finds the first or next CTL that matches a search criteria. The search criteria is established by the dwFindType and its associated pvFindPara.
#include <wincrypt.h>
PCCTL_CONTEXT WINAPI CertFindCTLInStore(
HCERTSTORE hCertStore, // in
DWORD dwMsgAndCertEncodingType, // in
DWORD dwFindFlags, // in
DWORD dwFindType, // in
const void *pvFindPara, // in
PCCTL_CONTEXT pPrevCtlContext // in
);
If the SubjectUsage.cUsageIdentifier in the CTL_FIND_USAGE_PARA is 0, any CTL is a match.
If the ListIdentifier.cbData in the CTL_FIND_USAGE_PARA is 0, any list identifier is a match. If ListIdentifier.cbData is CTL_FIND_NO_LIST_ID_CBDATA, only a CTL without a list identifier is a match.
If pSigner in the CTL_FIND_USAGE_PARA is NULL, any CTL signer is a match and only the Issuer and SerialNumber fields in the pSigner's PCERT_INFO are used. If psigner is CTL_FIND_NO_SIGNER_PTR, only a CTL without a signer is a match.
A pointer to a read-only CTL context is returned. The CTL context must be freed by calling CertFreeCTLContext or it is implicitly freed when passed as the pPrevCtlContext on a subsequent call to CertFindCTLInStore. CertDuplicateCTLContext can be called to make a duplicate of the returned context. The returned CTL context may be added to a different certificate store using CertAddCTLContextToStore or a link to that CTL context can be added to a non-collection store using CertAddCTLLinkToStore. If a CTL matching the search criteria is not found, NULL is returned.
Call GetLastError to see the reason for any failures. This function has the following error codes:
Error code | Description |
---|---|
E_INVALIDARG | The hCertStore argument isn't the same as the hCertStore in the CTL context pointed to by the pPrevCtlContext argument. Invalid find type specified by dwFindType argument. |
CRYPT_E_NOT_FOUND | No CTLs in the store, or no CTL was found matching the find criteria, or reached the end of the store's list. |
The pPrevtrlContext parameter must be NULL to get the first CTL in the store. Successive CTLs that match the find criteria are retrieved by setting pPrevCTlContext to the pointer to the CTL_CONTEXT returned by a previous function call. Any certificates that do not meet the find criteria or that have been previously deleted by CertDeleteCTLFromStore. are skipped.
A returned pointer is freed when passed as the pPrevCtlContext on a subsequent call to the function. Otherwise, the pointer must be freed by calling CertFreeCTLContext. A non-NULL pPrevCtlContext passed to the function is always freed with a call to CertFreeCTLContext even if the function generates an error.
See CertFindCertificateInStore. All references to "certificate" should be changed to "CTL."
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.