Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
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.CreateCS")
set crypt = Server.CreateObject("Chilkat.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("ChilkatUtil.ChilkatCSP")
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>
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.