SmtpMail.SignatureHashAlgorithm Property


Gets or sets the hash algorithm for email digital signature.

[Visual Basic]
Public Property SignatureHashAlgorithm As SignatureHashAlgorithmType
[C#]
public SignatureHashAlgorithmType SignatureHashAlgorithm {get; set;}
[C++]
public: __property SignatureHashAlgorithmType^ get_SignatureHashAlgorithm();
public: __property void set_SignatureHashAlgorithm(SignatureHashAlgorithmType^);
[JScript]
public function get SignatureHashAlgorithm() : SignatureHashAlgorithmType;
public function set SignatureHashAlgorithm(SignatureHashAlgorithmType);

Property Value

One of SignatureHashAlgorithmType values.

Example

To learn more about email digital signature and encryption, please refer to Digital Signature and E-mail Encryption section.

Example

[Visual Basic, C#] The following example demonstrates how to load certificate to sign email content with EASendMail SMTP Component. To get the full samples of EASendMail, please refer to Samples section.

[VB - Sign Email with Certificate]

Try
    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    oMail.From = New MailAddress("test@emailarchitect.net")

    ' Find certificate by email adddress in My Personal Store. 
    ' The certificate can be imported by *.pfx file like this: 
    ' oMail.From.Certificate.Load("c:\test.pfx", "pfxpassword", Certificate.CertificateKeyLocation.CRYPT_USER_KEYSET) 
    ' Once the certificate is loaded to From, the email content will be signed automatically

    oMail.From.Certificate.FindSubject(oMail.From.Address,
        Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER,
        "My")

    ' Use sha256 hash algorithm 
    oMail.SignatureHashAlgorithm = SignatureHashAlgorithmType.SHA256
Catch exp As Exception
    Console.WriteLine("No sign certificate found for sender email: {0}", exp.Message)
End Try


[C# - Sign Email with Certificate] try { SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = "test@adminsystem.com"; // Find certificate by email adddress in My Personal Store. // The certificate can be also imported by *.pfx file like this: // oMail.From.Certificate.Load("c:\\test.pfx", "pfxpassword", Certificate.CertificateKeyLocation.CRYPT_USER_KEYSET); // Once the certificate is loaded to From, the email content will be signed automatically oMail.From.Certificate.FindSubject(oMail.From.Address, Certificate.CertificateStoreLocation.CERT_SYSTEM_STORE_CURRENT_USER, "My"); // Use sha256 hash algorithm oMail.SignatureHashAlgorithm = SignatureHashAlgorithmType.SHA256; } catch (Exception exp) { Console.WriteLine("No sign certificate found {0}", exp.Message); }

Signature Algorithm

You can use SignatureHashAlgorithm property to set signature algorithm to MD5, SHA1, SHA256, SHA384 or SHA512.

RSASSA-PSS Signature

If you need to use RSASSA-PSS signature scheme, you need a special version of EASendMail, please have a look at this topic:
RSASSA-PSS + RSA-OAEP Encryption with SHA256

See Also

SignatureHashAlgorithmType Enumeration
EncryptionAlgorithmType Enumeration
Digital Signature and E-mail Encryption
MailAddress.Certificate Property