Chilkat VB.NET Dkim Class Reference

Dkim

DomainKeys API for creating and verifying DKIM-Signature and DomainKey-Signature MIME (email) header fields. This API is included with the "Chilkat MIME" license. ("Chilkat MIME" may be referred to as "Chilkat S/MIME" on some chilkatsoft.com web pages. They are the same product.)

Object Creation

(C#)
Chilkat.Dkim obj = new Chilkat.Dkim();
(VB.NET)
Dim obj As New Chilkat.Dkim()

Properties

DkimAlg As String

The signing algorithm to be used in creating the DKIM-Signature. Possible values are "rsa-sha256" and "rsa-sha1". The default value is "rsa-sha256".

DkimBodyLengthCount As Integer

Optional body length count to set a maximum number of body bytes to be hashed when creating the DKIM-Signature field. The default value is 0, indicating that the entire body should be hashed.

DkimCanon As String

Canonicalization algorithm to be used for both header and body when creating the DKIM-Signature. Possible values are "simple" and "relaxed". The default value is "relaxed".

DkimDomain As String

The domain name of the signing domain when creating the DKIM-Signature.

DkimHeaders As String

A colon-separated list of header field names that identify headers presented to the signing algorithm when creating the DKIM-Signature. The default value is: "mime-version:date:message-id:subject:from:to:content-type".

DkimSelector As String

The selector to be used to form the DNS query for the public key. This property applies to creating a DKIM-Signature. For example, if the selector is "reykjavik" and the domain is "example-code.com", then the DNS query would be for "reykjavik._domainkey.example-code.com".

DomainKeyAlg As String

The signing algorithm to be used in creating the DomainKey-Signature. The only possible value is "rsa-sha1". The default value is "rsa-sha1".

DomainKeyCanon As String

Canonicalization algorithm to be used for when creating the DomainKey-Signature. Possible values are "simple" and "nofws". The default value is "nofws".

DomainKeyDomain As String

The domain name of the signing domain when creating the DomainKey-Signature.

DomainKeyHeaders As String

A colon-separated list of header field names that identify headers presented to the signing algorithm when creating the DomainKey-Signature. The default value is: "mime-version:date:message-id:subject:from:to:content-type".

DomainKeySelector As String

The selector to be used to form the DNS query for the public key. This property applies to creating a DomainKey-Signature. For example, if the selector is "reykjavik" and the domain is "example-code.com", then the DNS query would be for "reykjavik._domainkey.example-code.com".

EnableEvents As Boolean

This property must be set to True to enable events. By default, it is False.

LastErrorHtml As String (ReadOnly)

Error information in HTML format for the last method called.

LastErrorText As String (ReadOnly)

Error information in plain-text format for the last method called.

LastErrorXml As String (ReadOnly)

Error information in XML format for the last method called.

Methods

Function AddDkimSignature(ByVal mimeIn As Byte()) As Byte()

Constructs and prepends a DKIM-Signature header to the MIME. Prior to calling this method, your program must set both the DkimDomain and DkimSelector properties, and it must load a private key by calling LoadDkimPk or LoadDkimPkFile.

Returns an empty byte array on failure

(VB.NET) Add DKIM-Signature Header to MIME / Email

(VB.NET) Send DKIM Signed Email

Function AddDomainKeySignature(ByVal mimeIn As Byte()) As Byte()

Constructs and prepends a DomainKey-Signature header to the MIME. Prior to calling this method, your program must set both the DomainKeyDomain and DomainKeySelector properties, and it must load a private key by calling LoadDomainKeyPk or LoadDomainKeyPkFile.

Returns an empty byte array on failure

(VB.NET) Add DomainKey-Signature Header to MIME / Email

Function LoadDkimPk(ByVal privateKey As String, ByVal optionalPassword As String) As Boolean

Loads an RSA private key to be used for creating a DKIM-Signature. Any valid RSA private key format that is not binary, such as PEM or XML, may be passed to this method. This method will automatically determine the format and parse it correctly. A password is only required if key is encrypted, such as for encrypted PEM.

Returns true for success, false for failure.

Function LoadDkimPkBytes(ByVal privateKeyDer As Byte(), ByVal optionalPassword As String) As Boolean

Loads an RSA private key to be used for creating a DKIM-Signature. Any valid RSA private key binary format, such as DER, may be passed to this method. This method will automatically determine the format and parse it correctly. A password is only required if key is encrypted.

Returns true for success, false for failure.

Function LoadDkimPkFile(ByVal privateKeyFilePath As String, ByVal optionalPassword As String) As Boolean

Loads an RSA private key file to be used for creating a DKIM-Signature. The file name contains any valid RSA private key format, such as DER, PKCS8, PEM, XML, etc. This method will automatically determine the format and parse it correctly. A password is only required if key is encrypted, such as for encrypted PEM or encrypted PKCS8.

Returns true for success, false for failure.

Function LoadDomainKeyPk(ByVal privateKey As String, ByVal optionalPassword As String) As Boolean

Loads an RSA private key to be used for creating a DomainKey-Signature. Any valid RSA private key format that is not binary, such as PEM or XML, may be passed to this method. This method will automatically determine the format and parse it correctly. A password is only required if key is encrypted, such as for encrypted PEM.

Returns true for success, false for failure.

Function LoadDomainKeyPkBytes(ByVal privateKeyDer As Byte(), ByVal optionalPassword As String) As Boolean

Loads an RSA private key to be used for creating a DomainKey-Signature. Any valid RSA private key binary format, such as DER, may be passed to this method. This method will automatically determine the format and parse it correctly. A password is only required if key is encrypted.

Returns true for success, false for failure.

Function LoadDomainKeyPkFile(ByVal privateKeyFilePath As String, ByVal optionalPassword As String) As Boolean

Loads an RSA private key file to be used for creating a DomainKey-Signature. The file name contains any valid RSA private key format, such as DER, PKCS8, PEM, XML, etc. This method will automatically determine the format and parse it correctly. A password is only required if key is encrypted, such as for encrypted PEM or encrypted PKCS8.

Returns true for success, false for failure.

Function LoadPublicKey(ByVal selector As String, ByVal domain As String, ByVal publicKey As String) As Boolean

Caches a public key to be used for verifying DKIM and DomainKey signatures for a given selector and domain. The publicKey is a string containing an RSA public key in any text format, such as XML, PEM, etc. This method will automatically detect the format and load the public key correctly. This method is useful for testing DKIM and DomainKey verification when your public key has not yet been installed in DNS.

Returns true for success, false for failure.

Function LoadPublicKeyFile(ByVal selector As String, ByVal domain As String, ByVal publicKeyFilepath As String) As Boolean

Caches a public key to be used for verifying DKIM and DomainKey signatures for a given selector and domain. The publicKeyFilepath is a filepath of an RSA public key in any format. This method will automatically detect the format and load the public key correctly. This method is useful for testing DKIM and DomainKey verification when your public key has not yet been installed in DNS.

Returns true for success, false for failure.

Function NumDkimSignatures(ByVal mimeData As Byte()) As Integer

Returns the number of DKIM-Signature header fields found in mimeData.

Function NumDomainKeySignatures(ByVal mimeData As Byte()) As Integer

Returns the number of DomainKey-Signature header fields found in mimeData.

Function PrefetchPublicKey(ByVal selector As String, ByVal domain As String) As Boolean

Useful if your application is going to verify many emails from a single domain (or a few domains). This eliminates the need to do a DNS lookup to fetch the public key each time an email's DKIM or DomainKey signature is verified.

This method may be called multiple times -- once for each selector/domain to be pre-fetched. The verify methods (VerifyDkimSignature and VerifyDomainKeySignature) will use a pre-fetched key if the selector and domain match.

Returns true for success, false for failure.

Function SaveLastError(ByVal filename As String) As Boolean

Saves the last error information to an XML formatted file.

Function UnlockComponent(ByVal unlockCode As String) As Boolean

Unlocks the component allowing for the full functionality to be used. If this method unexpectedly returns False, examine the contents of the LastErrorText property to determine the reason for failure.

Returns true for success, false for failure.

Function VerifyDkimSignature(ByVal sigIndex As Integer, ByVal mimeData As Byte()) As Boolean

Verifies the Nth DKIM-Signature header in the mimeData. (In most cases, there is only one signature.) The 1st signature is at sigIndex 0.

Important: Many anti-virus programs, such as AVG, will modify the MIME of an email as it is received. This will cause DKIM signature verification to fail because the body of the MIME is modified.

Returns true for success, false for failure.

Function VerifyDomainKeySignature(ByVal sigIndex As Integer, ByVal mimeData As Byte()) As Boolean

Verifies the Nth DomainKey-Signature header in the mimeData. (In most cases, there is only one signature.) The 1st signature is at sigIndex 0.

Important: Many anti-virus programs, such as AVG, will modify the MIME of an email as it is received. This will cause DomainKey signature verification to fail because the body of the MIME is modified.

Returns true for success, false for failure.