Classic ASP
Classic ASP
Check if an Email Was Received Digitally Signed
See more Email Object Examples
Demonstrates the read-only Chilkat Email.ReceivedSigned property, which is true if the email was originally received carrying one or more digital signatures. Knowing a message was signed is separate from knowing the signature checked out, so this example also reads SignaturesValid to report whether the signed content verified.
Background: A digital signature on an email (S/MIME) provides two things: authenticity (it was really sent by the holder of a particular certificate) and integrity (the content was not altered in transit). The sender signs a hash of the message with their private key; the recipient verifies it with the sender's public certificate.
ReceivedSigned simply tells you a signature is present — verifying it is a separate step exposed through SignaturesValid.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Demonstrates the read-only Email.ReceivedSigned property, which is true if this
' email was originally received with a digital signature. Use SignaturesValid to
' determine whether the signed content actually verified.
set email = Server.CreateObject("Chilkat.Email")
success = email.LoadEml("qa_data/eml/signed.eml")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( email.LastErrorText) & "</pre>"
Response.End
End If
If (email.ReceivedSigned = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "This email was received with a digital signature.") & "</pre>"
If (email.SignaturesValid = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "All signatures are valid.") & "</pre>"
Else
Response.Write "<pre>" & Server.HTMLEncode( "One or more signatures are NOT valid.") & "</pre>"
End If
Else
Response.Write "<pre>" & Server.HTMLEncode( "This email was not signed.") & "</pre>"
End If
' Note: Paths such as "qa_data/..." are relative local filesystem paths,
' relative to the current working directory of the running application.
%>
</body>
</html>