Click or drag to resize
MimeKit

DkimSigner Class

A DKIM signer.
Inheritance Hierarchy

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

The DkimSigner type exposes the following members.

Constructors
  NameDescription
Protected methodDkimSigner(String, String, DkimSignatureAlgorithm)
Initializes a new instance of the DkimSigner class.
Public methodDkimSigner(AsymmetricKeyParameter, String, String, DkimSignatureAlgorithm)
Initializes a new instance of the DkimSigner class.
Public methodDkimSigner(Stream, String, String, DkimSignatureAlgorithm)
Initializes a new instance of the DkimSigner class.
Public methodCode exampleDkimSigner(String, String, String, DkimSignatureAlgorithm)
Initializes 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.)
Top
Methods
  NameDescription
Protected methodCreateSigningContext
Create the digest signing context.
(Inherited from DkimSignerBase.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Protected methodGetTimestamp
Get the timestamp value.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(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
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
A DKIM signer.
Examples
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