Sample code for 30+ languages & platforms
B4X

Get Certificate Policy

See more Certificates Examples

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

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim cert As ChilkatCert
cert.Initialize("cert")

success = cert.LoadFromFile("qa_data/certs/sample.cer")
If success = False Then
    Log(cert.LastErrorText)
    Return
End If


'  The certificatePolicies OID is 2.5.29.32
Dim oid As String = "2.5.29.32"
Dim strXml As String = cert.GetExtensionAsXml(oid)
If cert.LastMethodSuccess = True Then
    Log(strXml)

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

    Dim xml As ChilkatXml
    xml.Initialize
    xml.LoadXml(strXml)
    Log("Policy OID = " & xml.GetChildContent("sequence|oid"))
End If