Sign Method


Adds the digital signature to the message.

Signing a message with digital signature allows recipients (who have their own public keys) to confirm the authenticity of the message sender and verify its integrity (that the message was not altered during transmission).

 

To add the digital signature to a message, the developer must select the digital certificate containing the public key of message recipient using the SelectSenderCert method.

 

Then, the developer should add the digital signature using the Sign method. If the message was already signed, nothing happens. The developer can check if the message is signed using the Signed property.

 

Nowadays, it's recommended to use SHA-256 as signature algorithm. It's more secure than the default one (usually SHA-1). Some mail clients like Mozilla Thunderbird may consider SHA-1 signatures not trusted at all.


[Visual Basic]

blnResult = ObjectName.Sign

 
Parameters: None 
Return value As Boolean True if successful, False if error has occurred.  

Usage example:

' This example loads the message from file and signs it.
Dim objSMIME, objMsg ' Using Visual Basic to create the objects Set objMsg = CreateObject("MailBee.Message") Set objSMIME = CreateObject("MailBee.SMIME") ' Using ASP to create the objects 'Set objMsg = Server.CreateObject("MailBee.Message") 'Set objSMIME = Server.CreateObject("MailBee.SMIME") ' Specify MailBee license key objSMIME.LicenseKey = "put your license key here" ' Load the message from file objMsg.ImportFromFile "mail_src.eml" ' Specify the message for the further processing Set objSMIME.Message = objMsg ' These lines are needed if we want to use SHA-256 signature (required by Thunderbird) objSMIME.CSP = "Microsoft Strong Cryptographic Provider" objSMIME.AlgorithmSigning = "2.16.840.1.101.3.4.2.1" ' Select the sender's certificate form the system storage of the current user If objSMIME.SelectSenderCert ("MY", 0, "", "", "", objMsg.PureFromAddr, "") Then ' Sign the message with selected certificate objSMIME.Sign ' Check if any errors occurred If (objSMIME.SMIMEError <> SMIME_OK) Or (objSMIME.SMIMESpecificError <> SMIME_OK) Then ' Display the code of the last occurred error ' In ASP use Response.Write instead of MsgBox MsgBox "SMIMEError = " & objSMIME.SMIMEError & " SMIMESpecificError = " & _ objSMIME.SMIMESpecificError End If End If

See Also:

SelectSenderCert Method, SignAndEncrypt Method, Signed Property


Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.