Classic ASP
Classic ASP
Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
set certStore = Server.CreateObject("Chilkat.CertStore")
' This only loads the contents of the PFX file into the certStore object.
' It is not importing the PFX into the Windows certificate stores.
pfxPassword = "badssl.com"
success = certStore.LoadPfxFile("qa_data/pfx/badssl.com-client.p12",pfxPassword)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( certStore.LastErrorText) & "</pre>"
Response.End
End If
' Examine each certificate (loaded from the PFX) in this certStore object
set cert = Server.CreateObject("Chilkat.Cert")
numCerts = certStore.NumCertificates
i = 0
Do While i < numCerts
success = certStore.GetCert(i,cert)
Response.Write "<pre>" & Server.HTMLEncode( "hasPrivateKey=" & cert.HasPrivateKey() & ", " & cert.SubjectCN) & "</pre>"
i = i + 1
Loop
%>
</body>
</html>