Sample code for 30+ languages & platforms
.NET Core C#

Get Certificate Policy

See more Certificates Examples

Demonstrates how to get a certificate's policy OIDs (if any)

Chilkat .NET Core C# Downloads

.NET Core C#
bool success = false;

Chilkat.Cert cert = new Chilkat.Cert();

success = cert.LoadFromFile("qa_data/certs/sample.cer");
if (success == false) {
    Debug.WriteLine(cert.LastErrorText);
    return;
}

// The certificatePolicies OID is 2.5.29.32
string oid = "2.5.29.32";
string strXml = cert.GetExtensionAsXml(oid);
if (cert.LastMethodSuccess == true) {
    Debug.WriteLine(strXml);

    // Sample result:
    // <sequence><sequence><oid>2.16.840.1.101.2.1.11.39</oid></sequence></sequence>

    Chilkat.Xml xml = new Chilkat.Xml();
    xml.LoadXml(strXml);
    Debug.WriteLine("Policy OID = " + xml.GetChildContent("sequence|oid"));
}