CertDeleteCertificateFromStore function

The CertDeleteCertificateFromStore function deletes the specified certificate context from the certificate store.

Syntax

BOOL CertDeleteCertificateFromStore(
  PCCERT_CONTEXT pCertContext
);

Parameters

pCertContext

A pointer to the CERT_CONTEXT structure to be deleted.

Return Value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. For extended error information, call GetLastError. One possible error code is the following.

Return code Description
E_ACCESSDENIED
Indicates the store was opened as read-only and a delete operation is not allowed.

Remarks

After a certificate is deleted from a store, all subsequent attempts to get or find that certificate in that store will fail. However, memory allocated for the certificate is not freed until all duplicated contexts have also been freed.

The CertDeleteCertificateFromStore function always frees pCertContext by calling the CertFreeCertificateContext function, even if an error is encountered. Freeing the context reduces the context's reference count by one. If the reference count reaches zero, memory allocated for the certificate is freed.

Examples

For an example that uses this function, see Example C Program: Deleting Certificates from a Certificate Store.

Requirements

   
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See Also

CertDeleteCRLFromStore

CertFreeCertificateContext

Certificate Functions