CertVerifyCRLRevocation (crypt32)
Last changed: flyhippo@flyhippo.org-194.186.67.226

.
Summary
The CertVerifyCRLRevocation function check a CRL to determine whether a subject's certificate has or has not been revoked. The new Certificate Chain Verification Functions are recommended instead of the use of this function.

C# Signature:

[DllImport("crypt32.dll", SetLastError=true)]
public static extern bool CertVerifyCRLRevocation(
    uint    dwCertEncodingType,
    IntPtr    pCertId,
    uint    cCrlInfo,
    [In, MarshalAs(UnmanagedType.LPArray,SizeParamIndex=2)]
    IntPtr[] rgpCrlInfo);

VB Signature:

Declare Function CertVerifyCRLRevocation Lib "crypt32.dll" (TODO) As TODO

User-Defined Types:

CRL_CONTEXT

CERT_CONTEXT

Notes:

None.

Tips & Tricks:

Better use CertFindCertificateInCRL

Sample Code:

    IntPtr crlContext = CertCreateCRLContext(...)
    IntPtr certContext = CertFindCertificateInStore(...)
    // Extract CRL_INFO
    CRL_CONTEXT crlCtx = (CRL_CONTEXT) Marshal.PtrToStructure(crlContext, typeof(CRL_CONTEXT));
    IntPtr[] arrCrlInf = new IntPtr[1];
    arrCrlInf[0] = crlCtx.pCrlInfo;

    // Extract CERT_INFO
    CERT_CONTEXT certCtx = (CERT_CONTEXT) Marshal.PtrToStructure(certContext, typeof(CERT_CONTEXT));

    if(! CertVerifyCRLRevocation(0x00010001, // X509_ASN_ENCODING | PKCS_7_ASN_ENCODING
        certCtx.pCertInfo, 1, arrCrlInf))
    {
        // Certificate is in CRL
    }
    else
    {
        // Certificate is not in CRL
    }

Alternative Managed API:

Do you know one? Please contribute it!

Documentation