title: How to check client certificate revocation during validation process with local CRL file (C#)
body: <p>I am trying to validate a client certificate using <code>HttpClientHandler.ServerCertificateCustomValidationCallback</code>. I have built my <code>x509chain</code> with my <code>ChainPolicy</code> parameters.</p>
  
  <p>I have locally my CRL (.pem) file and i would like to add it to the revocation process.</p>
  
  <p>I was thinking of doing something like <a href="http://blog.ginzburgconsulting.com/real-time-crl-validation-for-x-509-certificates-in-net/" rel="nofollow noreferrer">CRL validation</a>, importing into my <code>X509Certificate</code> an <code>X509Extension</code> with a distributionPoint oid but i have trouble understanding it.</p>
  
  <p>Here is a piece of my callback code</p>
  
  <pre><code>private static Func&lt;HttpRequestMessage, X509Certificate2, X509Chain, SslPolicyErrors, bool&gt;
      ServerCertificateCustomValidationCallback()
  {
      return (sender, cert, chain, sslPolicyErrors) =&gt;
      {
          X509Certificate2 ca = new X509Certificate2(@"pathToCa\\ca.crt");
  
          X509Chain chai = new X509Chain();
          chai.ChainPolicy.ExtraStore.Add(ca);
          chai.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
          chai.ChainPolicy.RevocationMode = X509RevocationMode.Online;
          chai.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
          chai.ChainPolicy.VerificationTime = DateTime.Now;
          try
          {
              if (!chai.Build(cert))
              {
                  return false;
              }
              foreach (X509ChainStatus status in chai.ChainStatus)
              {
                  if (status.Status == X509ChainStatusFlags.UntrustedRoot) continue;
                  if (status.Status == X509ChainStatusFlags.OfflineRevocation) continue;
                  if (status.Status == X509ChainStatusFlags.RevocationStatusUnknown) continue;
                  return false;
              }
  
          }
          catch (Exception e)
          {
              throw e;
          }
  
          return true;
      };
  }
  </code></pre>
  
  <p>Thank for your help &amp; clarification</p>