Documentation ¶
Overview ¶
Package dkim is used for signing emails with DKIM.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Hash = crypto.SHA256
Hash is the algorithm used for hashing. SHA256 is recommended by the RFC. Change this to crypto.SHA1 if you need to.
var SignHeaderFields = []string{
"From",
"Reply-to",
"Subject",
"Date",
"To",
"Cc",
"Resent-Date",
"Resent-From",
"Resent-Sender",
"Resent-To",
"Resent-Cc",
"In-Reply-To",
"References",
"List-Id",
"List-Help",
"List-Unsubscribe",
"List-Subscribe",
"List-Post",
"List-Owner",
"List-Archive",
}
SignHeaderFields lists the header names to sign. These headers are recommended in RFC 6376 section 5.4.1. The list can be changed at will. This implementation signs each instance, if the header field occurs more than once. The basic rule for choosing fields to include is to select those fields that constitute the "core" of the message content. Note that "From" is required and "DKIM-Signature" is implicitly signed.
Functions ¶
func GenerateKeyPair ¶
GenerateKeyPair returns a new PEM encoded private key and base64 encoded public key.
func ParsePrivateKey ¶
func ParsePrivateKey(keyPEM []byte) (key *rsa.PrivateKey, err error)
ParsePrivateKey returns the private key from a PEM formatted block.
Types ¶
type Domain ¶
type Domain struct { Name string Selector string PrivateKey *rsa.PrivateKey }
Domain used for DKIM signing. Which domain to use for signing is left to the user. Common (and best) practice is to use the same domain as in the Sender: or From: header.
func ReadDomain ¶
ReadDomain creates a signing domain from name, selector and file with PEM encoded private key.
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
Signature represents DKIM-Signature header field.
func NewSignature ¶
NewSignature creates a signature signed by the specified domain.
func (*Signature) BodyWriter ¶
BodyWriter returns a writer that should receive the message body for calculating the body hash in the "bh=" tag. The body should be written before SignHeader is called. It is assumed that the body has proper CRLF line ends.
func (*Signature) SignHeader ¶
SignHeader adds the header fields in SignHeaderFields from the mail.Header to the signature. The header hash is signed with the domain private key and used for the "b=" tag.