Need help reading from Certificate Revocation Lists in .NET

From: anonymoustechie2005 (anonymoustechie2005_at_discussions.microsoft.com)
Date: 06/24/05


Date: Thu, 23 Jun 2005 19:44:01 -0700

If there is anyone who is familiar with X509 certificates and certificate
revocation lists, any help would be appreciated.

We are trying to build a VB.NET-based tool that will check if a certificate
is found in a certificate revocation list (CRL) -
utilizing P/Invoke and the Crypt32.dll API. The first approach we tried to
use had these steps:
 
1. Place the certificate in a CERT Context using the function
CertCreateCertificateContext.
2. Place CRL in a CRL Context using the function CertCreateCRLContext.
3. Check if the cert is in the CRL by using the function
CertFindCertificateInCRL,
   passing in as parameters the CERT Context and CRL Context.

        
Here’s what the actual code looks like:
 

Dim contextCert As IntPtr = IntPtr.Zero
Dim contextCRL As IntPtr = IntPtr.Zero
Dim contextCertInCRL As IntPtr = IntPtr.Zero
Dim wasCRLSearched As Boolean
 
contextCert = CertCreateCertificateContext(MY_ENCODING_TYPE, cert,
Convert.ToUInt32(cert.Length))
contextCRL = CertCreateCRLContext(MY_ENCODING_TYPE, crl,
Convert.ToUInt32(crl.Length))
 
'CertFindCertificateInCRL returns True if the CRL was searched.
'If the certificate is found in the CRL, the parameter contextCertInCRL is
updated with a pointer to the entry.
'Otherwise, it is set to NULL. The returned entry is not allocated and must
not be freed.
wasCRLSearched = CertFindCertificateInCRL(contextCert, contextCRL,
Convert.ToUInt32(0), IntPtr.Zero, contextCertInCRL)
 
If wasCRLSearched = True Then
      
        'check if the parameter was changed
        If contextCertInCRL.Equals(NULL) OR contextCertInCRL.Equals(IntPtr.Zero) Then
                Return False 'certificate is not found in the CRL
        Else
                   Return True 'certificate is found in the CRL
        End If

Else
      'TO DO: show message that CRL search was not successful
     
End If

 
We found out that the function CertCreateCRLContext() may be incomplete in
its implementation from Microsoft.
According to MSDN, the function is supposed to take an encoded CRL in raw
format and return a PCCRL_CONTEXT structure,
which contains all of the CRL data packaged and easily accessible. But
according to a source we found,
the current implementation of CertCreateCRLContext does not do any data
decoding for the encoded CRL input. It just
creates a new PCCRL_CONTEXT structure then copies the encoded data into one
of its fields. No data decoding is
performed and so the returned structure is no more useful than the encoded
data.
 
If this is true, can somebody suggest other approaches that would work? With
our current approach,
we are not getting any errors, but we are not getting the desired results
either. We use a manual reading check of
the CRL file to verify the correctness of the code. The code returns False
even if the certificate is in the CRL.

Again, any help would be appreciated, thanks!



Relevant Pages

  • Re: Thawte Digital Certificate Revocation List Issue
    ... > I am new to digital certificates and cannot get the Thawte certificate ... It's been awhile since I played with the Thawte certificates. ... Microsoft requires the cert ... CRL so Outlook doesn't know where to get ...
    (microsoft.public.security)
  • Re: Newbie wants to learn about PKI Server 2003......
    ... 2003 PKI Certificate Security", and have been lurking here for a bit. ... We will implement a 2 tier heirarchy, with the Root CA being offline. ... All clients that attempt revocation checking will first attempt to retrieve the CRL from the ... level below a self-signed cert, so applications that are 3280 compliant would never check the ...
    (microsoft.public.windows.server.security)
  • Help PKI installation - lots of questions !
    ... One STAND ALONE ROOT CA called SACAMX00 (SA stand for Stand Alone, ... AMERICAS Sub & CA ASIA Sub ... Client use this to find Delta CRL ... publish my CRL again even if no certificate are revoked? ...
    (microsoft.public.security)
  • Re: Help PKI installation - lots of questions !
    ... One STAND ALONE ROOT CA called SACAMX00 (SA stand for Stand Alone, ... AMERICAS Sub & CA ASIA Sub ... Client use this to find Delta CRL ... publish my CRL again even if no certificate are revoked? ...
    (microsoft.public.security)
  • Re: revoking ipsec certificate doesnt work
    ... It's possible to publish manually the update delta and full CRL using the CA ... MMC SnapIn on the Server. ... my test VPN client never checks if the ... Server 2003 SP1 without any problem after the certificate is revoked nearly ...
    (microsoft.public.windows.server.security)