Sample code for 30+ languages & platforms
Classic ASP

Load PEM and List Certificates

Demonstrates how to load a PEM containing certificates and accesses each individual certificate.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

success = 0

set pem = Server.CreateObject("Chilkat.Pem")

' Load the .p7b from a file.
success = pem.LoadPemFile("/Users/chilkat/testData/p7b/cacert_mozilla.pem")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( pem.LastErrorText) & "</pre>"
    Response.End
End If

numCerts = pem.NumCerts
If (numCerts = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( ("Error: Expected the PEM to contain certificates.")) & "</pre>"
    Response.End
End If

' Access each certificate and show the Subject CN (Common Name)
For i = 1 To numCerts
    ' cert is a Chilkat.Cert
    Set cert = pem.GetCert(i - 1)
    Response.Write "<pre>" & Server.HTMLEncode( i & ": " & cert.SubjectCN) & "</pre>"

Next

%>
</body>
</html>