title: how to parse X509 ssl certificate custom extension "certificate policy"?
body: <p>I am trying to parse X509 sertificate custom extension. (I have created a self signed certificate with custom extentions of type "certificate policy"). I need to parse this "certificate policy" and its values. Programatically I can get the name of the custom extention that is "certificate policy" but I can not get its values..The code that i am using is as the following:</p>
  
  <pre><code>    public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
      {
          var cert = (X509Certificate2)certificate;
          foreach (X509Extension ext in cert.Extensions)
          {
            //  AsnEncodedData x = new AsnEncodedData(ext.Oid, ext.RawData);
              MessageBox.Show("Name: " + ext.Oid.FriendlyName + "\nValue: " + ext.Oid.Value);
  
          }
  
          return true;
      }
  </code></pre>
  
  <p>This code onlye display "Certificate Policy" but I need the parse elements of the policy shown in below:</p>
  
  <p>The values under the Certificate Policy elements:</p>
  
  <pre><code>[1]Certificate Policy:
       Policy Identifier=1.2.3.4
  [2]Certificate Policy:
       Policy Identifier=1.5.6.7.8
  [3]Certificate Policy:
       Policy Identifier=1.3.5.8
       [3,1]Policy Qualifier Info:
            Policy Qualifier Id=CPS
            Qualifier:
                 Tarzano
       [3,2]Policy Qualifier Info:
            Policy Qualifier Id=User Notice
            Qualifier:
                 Notice Reference:
                      Organization=Tarzano Ltd
                      Notice Number=1, 2, 3, 4
                 Notice Text=Buraya mesaj yazilabilir
  </code></pre>
  
  <p>thanks for help !</p>