Dkim |
public DkimSignatureAlgorithm SignatureAlgorithm { get; set; }
Gets or sets the algorithm to use for signing.
Creates a new DkimSigner.
Security Note |
---|
Due to the recognized weakness of the SHA-1 hash algorithm and the wide availability of the SHA-256 hash algorithm (it has been a required part of DKIM since it was originally standardized in 2007), it is recommended that RsaSha1 NOT be used. |
public static void DkimSign (MimeMessage message) { var headers = new HeaderId[] { HeaderId.From, HeaderId.Subject, HeaderId.Date }; var signer = new DkimSigner ("privatekey.pem", "example.com", "brisbane", DkimSignatureAlgorithm.RsaSha256) { HeaderCanonicalizationAlgorithm = DkimCanonicalizationAlgorithm.Simple, BodyCanonicalizationAlgorithm = DkimCanonicalizationAlgorithm.Simple, AgentOrUserIdentifier = "@eng.example.com", QueryMethod = "dns/txt", }; // Prepare the message body to be sent over a 7bit transport (such as older versions of SMTP). // Note: If the SMTP server you will be sending the message over supports the 8BITMIME extension, // then you can use `EncodingConstraint.EightBit` instead. message.Prepare (EncodingConstraint.SevenBit); signer.Sign (message, headers); }