![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
Find Certificates that can be used for Signing
This ASP script shows how to iterate over the certificates on a computer to find those that can be used for signing. <html><body>
<%
' What certificates exist on my computer, and which
' ones can I use for creating digital signatures?
set ccs = Server.CreateObject("Chilkat_9_5_0.CreateCS")
set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")
unlocked = crypt.UnlockComponent("anything begins 30-day trial")
If unlocked = 0 Then
' Failed to unlock...
End If
' Use the Microsoft Enhanced Cryptographic Service Provider
' Add a reference to ChilkatUtil for the ChilkatCSP object
set csp = Server.CreateObject("Chilkat.Csp")
csp.SetProviderMicrosoftEnhanced
crypt.SetCSP csp
' -------------------------------------------------------
' Check the local machine certificate store.
' -------------------------------------------------------
Set certStore = ccs.OpenLocalSystemStore()
Response.write "<b>Local Machine Certificate Store</b>"
Response.write "<table border=1>"
For i = 0 To certStore.NumCertificates - 1
Set cert = certStore.GetCertificate(i)
Response.write "<tr><td>"
' Display the certificate we are testing..
Response.write "<font size='+1'><b>" & cert.SubjectDN & "</b></font><br>"
' Set the certificate to be used for signing, and our output string encoding.
crypt.SetSigningCert cert
crypt.EncodingMode = "base64"
' Try signing....
signature = crypt.SignStringENC("This is a test")
If Len(signature) = 0 Then
' Failed to create signature
Response.write "FAILED<br>"
If cert.HasPrivateKey() = 0 Then
Response.write "NO PRIVATE KEY<br>"
End If
Response.write "<p>" & crypt.LastErrorHtml
Else
Response.write "SUCCESS!<br>"
Response.write "<p>" & crypt.LastErrorHtml
End If
Response.write "</td></tr>"
Next
Response.write "</table>"
%>
</body></html>
|
|||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.