Dkim Signer(String, String, String, Dkim Signature Algorithm) Constructor
Initialize a new instance of the DkimSigner class.
Definition
Namespace: MimeKit.Cryptography
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
Assembly: MimeKit.Cryptography (in MimeKit.Cryptography.dll) Version: 5.0.0
C#
public DkimSigner(
string fileName,
string domain,
string selector,
DkimSignatureAlgorithm algorithm = DkimSignatureAlgorithm.RsaSha256
)Parameters
- fileName String
- The file containing the private key.
- domain String
- The domain that the signer represents.
- selector String
- The selector subdividing the domain.
- algorithm DkimSignatureAlgorithm (Optional)
- The signature algorithm.
Remarks
Creates a new DkimSigner.
Example
C#
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);
}
Exceptions
| ArgumentNullException |
fileName is . -or- domain is . -or- selector is . |
| ArgumentException | fileName is a zero-length string, contains only white space, or contains one or more invalid characters. |
| FormatException | The file did not contain a private key. |
| DirectoryNotFoundException | fileName is an invalid file path. |
| FileNotFoundException | The specified file path could not be found. |
| UnauthorizedAccessException | The user does not have access to read the specified file. |
| IOException | An I/O error occurred. |