Click or drag to resize
MimeKit

DkimSigner Class

A DKIM signer.
Inheritance Hierarchy
SystemObject
  MimeKit.CryptographyDkimSignerBase
    MimeKit.CryptographyDkimSigner

Namespace: MimeKit.Cryptography
Assembly: MimeKit (in MimeKit.dll) Version: 4.3.0
Syntax
C#
public class DkimSigner : DkimSignerBase

The DkimSigner type exposes the following members.

Constructors
 NameDescription
Protected methodDkimSigner(String, String, DkimSignatureAlgorithm) Initialize a new instance of the DkimSigner class.
Public methodDkimSigner(AsymmetricKeyParameter, String, String, DkimSignatureAlgorithm) Initialize a new instance of the DkimSigner class.
Public methodDkimSigner(Stream, String, String, DkimSignatureAlgorithm) Initialize a new instance of the DkimSigner class.
Public methodCode exampleDkimSigner(String, String, String, DkimSignatureAlgorithm) Initialize a new instance of the DkimSigner class.
Top
Properties
 NameDescription
Public propertyCode exampleAgentOrUserIdentifier Get or set the agent or user identifier.
Public propertyCode exampleBodyCanonicalizationAlgorithm Get or set the canonicalization algorithm to use for the message body.
(Inherited from DkimSignerBase)
Public propertyCode exampleDomain Get the domain that the signer represents.
(Inherited from DkimSignerBase)
Public propertyCode exampleHeaderCanonicalizationAlgorithm Get or set the canonicalization algorithm to use for the message headers.
(Inherited from DkimSignerBase)
Protected propertyPrivateKey Gets the private key.
(Inherited from DkimSignerBase)
Public propertyCode exampleQueryMethod Get or set the public key query method.
Public propertyCode exampleSelector Get the selector subdividing the domain.
(Inherited from DkimSignerBase)
Public propertyCode exampleSignatureAlgorithm Get or set the algorithm to use for signing.
(Inherited from DkimSignerBase)
Public propertySignaturesExpireAfter Get or set the timespan after which signatures are no longer valid.
(Inherited from DkimSignerBase)
Top
Methods
 NameDescription
Protected methodCreateSigningContext Create the digest signing context.
(Inherited from DkimSignerBase)
Public methodEquals
(Inherited from Object)
Protected methodFinalize
(Inherited from Object)
Public methodGetHashCode
(Inherited from Object)
Protected methodGetTimestamp Get the timestamp value.
Public methodGetType
(Inherited from Object)
Protected methodMemberwiseClone
(Inherited from Object)
Public methodCode exampleSign(MimeMessage, IListHeaderId) Digitally sign the message using a DomainKeys Identified Mail (DKIM) signature.
Public methodCode exampleSign(MimeMessage, IListString) Digitally sign the message using a DomainKeys Identified Mail (DKIM) signature.
Public methodCode exampleSign(FormatOptions, MimeMessage, IListHeaderId) Digitally sign the message using a DomainKeys Identified Mail (DKIM) signature.
Public methodCode exampleSign(FormatOptions, MimeMessage, IListString) Digitally sign the message using a DomainKeys Identified Mail (DKIM) signature.
Public methodToString
(Inherited from Object)
Top
Remarks
A DKIM signer.
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);
}
See Also