Classic ASP
Classic ASP
Open Smartcard Certificate Store (or from USB Token)
See more Certificates Examples
Demonstrates how to open the certificate store of the smart card currently in the reader (or the USB token). Iterates over the certs found on the smartcard.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")
' Access the certificates on the smart card or USB token via the Chilkat certificate store class.
' Note: Always pass the empty string to OpenSmartcard.
' ---------------------------------------------------------------------------------------------------------
' The following is true only for Chilkat v10.1.1 and earlier:
' Also, the Chilkat CertStore class can only use MS CNG or CryptoAPI.
' Some smartcard/USB token drivers only support PKCS11 or ScMinidriver.
' You may get better results using Chilkat.Cert.LoadFromSmartcard because
' Cert.LoadFromSmartcard can automatically detect and utilize PKCS11, ScMinidriver, CNG, and CryptoAPI.
' ---------------------------------------------------------------------------------------------------------
' Starting in Chilkat versions after v10.1.1, OpenSmartcard also works with
' Apple Keychain and PKCS11 drivers on Windows, Linux, and MacOS.
' ---------------------------------------------------------------------------------------------------------
success = certStore.OpenSmartcard("")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( certStore.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( certStore.LastErrorText) & "</pre>"
' Iterate over certificates on the smartcard.
set cert = Server.CreateObject("Chilkat.Cert")
i = 0
numCerts = certStore.NumCertificates
Response.Write "<pre>" & Server.HTMLEncode( "numCerts = " & numCerts) & "</pre>"
Do While (i < numCerts)
success = certStore.GetCert(i,cert)
Response.Write "<pre>" & Server.HTMLEncode( cert.SubjectCN) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( cert.SerialNumber) & "</pre>"
If (cert.IsRsa() = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "key type is RSA") & "</pre>"
End If
If (cert.IsEcdsa() = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "key type is ECDSA") & "</pre>"
End If
Response.Write "<pre>" & Server.HTMLEncode( "has private key: " & cert.HasPrivateKey()) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "----") & "</pre>"
i = i + 1
Loop
%>
</body>
</html>