ASP Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

ASP Examples

ASP String
ASP Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar
ASP Upload
XML
XMP
Zip Compression

More Examples...
Email Object
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Icon

 

 

 

 

 

 

Create / Verify Digital Signature

Download Chilkat Crypt ActiveX

This ASP script shows how to create and verify a digital signature using a certificate.

<html>
<head>
<title>ASP Digital Signature Example</title>
</head>
<body>
<%

' Get an object to create a certificate store object
set ccs = Server.CreateObject("Chilkat.CreateCS")

' Open the local machine certificate store.
set certStore = ccs.OpenLocalSystemStore()

' Find the certificate matching the email address "matt@chilkatsoft.com"
set cert = certStore.FindCertBySubjectE("matt@chilkatsoft.com")
	
' Create a Chilkat encryption instance to do the public-key encryption.
set crypt = Server.CreateObject("Chilkat.Crypt2")

' Use the digital certificate we obtained from the local machine store.
crypt.SetSigningCert cert

' Any value passed to UnlockComponent begins the 30-day trial.
unlocked = crypt.UnlockComponent("30-day trial")

stringToSign = "This is a test"

' Create a digital signature for the data.
' Return the signature as a hexidecimalized string.
crypt.EncodingMode = "hex"

signature = crypt.SignStringENC(stringToSign)

' Show the details of what happened during signing.
Response.write crypt.LastErrorHtml & "<br><br>"

' Show the signature
Response.write "Signature: " & signature & "<br><br>"

' Now check to see if the signature is valid.
' Use a different ChilkatCrypt2 object for demonstration purposes.
set crypt2 = Server.CreateObject("Chilkat.Crypt2")
crypt2.EncodingMode = "hex"
unaltered = crypt2.VerifyStringENC(stringToSign,signature)
if (unaltered = 1) then
	Response.write "1) The message has not been altered<br><br>"
else
	Response.write "1) The message has been altered!<br><br>"
end if

' Alter the message and check again.
alteredMessage = stringToSign & "."
unaltered = crypt2.VerifyStringENC(alteredMessage,signature)
if (unaltered = 1) then
	Response.write "2) The message has not been altered<br><br>"
else
	Response.write "2) The message has been altered!<br><br>"
end if

' Let's look at the cert that was used to sign...
set cert2 = crypt2.GetLastCert()
if not (cert2 is nothing) then

	' Which cert was it?
	Response.write "Certificate used: " & cert2.SubjectDN & "<br><br>"
	
	' Has the certificate been revoked?
	if cert2.Revoked then
		Response.write "This certificate has been revoked!<br><br>"
	end if
	
	' Has the certificate expired?
	if cert2.Expired then
		Response.write "This certificate has expired!<br><br>"
	end if
	
	' Is the certificate signature valid?
	if cert2.SignatureVerified = 0 then
		Response.write "This certificate does not have a valid signature!<br><br>"
	end if
	
	' Does the certificate have a trusted root?
	if cert2.TrustedRoot = 0 then
		Response.write "This certificate does not have a trusted root!<br><br>"
	end if
	
end if
		
%>
</body>
</html>
 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.