You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Dolf Schimmel (Freeaqingme) 9892e025c8 Allow any body length, even if sigoptions.bodylength is set 5 years ago
.gitignore Initial commit 6 years ago
LICENSE Initial commit 6 years ago
README.md Merge branch 'master' of https://github.com/andres-erbsen/go-dkim 5 years ago
dkim.go Allow any body length, even if sigoptions.bodylength is set 5 years ago
dkimHeader.go Merge branch 'master' of https://github.com/andres-erbsen/go-dkim 5 years ago
dkim_test.go Allow any body length, even if sigoptions.bodylength is set 5 years ago
errors.go Allow any body length, even if sigoptions.bodylength is set 5 years ago
pubKeyRep.go Merge branch 'master' of https://github.com/andres-erbsen/go-dkim 5 years ago
watch new signature fro sign 6 years ago

README.md

go-dkim

Fork of toorop's DKIM with non-pointer API and bugfixes.

GoDoc

Getting started

Install

 	go get github.com/andres-erbsen/go-dkim

Warning: you need to use Go 1.4.2-master or 1.4.3 (when it will be available) see https://github.com/golang/go/issues/10482 fro more info.

Sign email

import (
	dkim "github.com/andres-erbsen/go-dkim"
)

func main(){
	// email is the email to sign (byte slice)
	// privateKey the private key (pem encoded, byte slice )
	dkim := dkim.NewDkim()
	options := dkim.NewSigOptions()
	options.PrivateKey = privateKey
	options.Domain = "mydomain.tld"
	options.Selector = "myselector"
	options.SignatureExpireIn = 3600
	options.BodyLength = 50
	options.Headers = []string{"from", "date", "mime-version", "received", "received"}
	options.AddSignatureTimestamp = true
	options.Canonicalization = "relaxed/relaxed"
	err := dkim.Sign(&email, options)
	// handle err..
}

Verify

import (
	dkim "github.com/toorop/go-dkim"
)

func main(){
	// email is the email to verify (byte slice)
	dkim := dkim.NewDkim()
	_, err := dkim.Verify(email)
}

Todo

  • handle z tag (copied header fields used for diagnostic use)
  • handle multiple dns records