Skip to content

Repository files navigation

Yet Another DKIM Verifier

Why not?

I found some DKIM solution for go, but I don’t like untested C binding and I have some time (thank you mr.Putin) I wrote this code for my pet project.

What can we do?

We can verify DKIM headers very fast. It is about 44mb per second on my laptop. We support custom resolving and custom cache logic.

TODO

  • Support Length tag
  • Support Time
  • Support ExpireTime
  • Support Copied header fields (z=)
  • Sign

How to use it?

package main
import (
"bufio""flag""fmt""os""github.com/kalloc/dkim"
)
// ./test path/to/emls/*.emlfuncmain() {
var (
filenamestringfp*os.Fileerrerrordk*dkim.DKIM
)
flag.Parse()
for_, filename=rangeflag.Args() {
fmt.Printf("Check: %s — ", filename)
iffp, err=os.Open(filename); err!=nil {
fmt.Printf("ERR-WRONG_FILE")
} elseifdk, _=dkim.ParseEml(bufio.NewReader(fp)); dk==nil {
fmt.Printf("ERR-DKIM_NOT_FOUND")
} elseif_, err=dk.GetPublicKey(); err!=nil {
fmt.Printf("ERR-DKIM_PK_NOT_FOUND")
} elseifdk.Verify() ==false {
fmt.Printf("ERR-DKIM_NOT_VERIFIED (Body is %v, Sig is %v)", dk.Status.ValidBody, dk.Status.Valid)
} else {
fmt.Printf("OK")
}
fmt.Printf("\n")
}
}

About

Golang DKIM Verifier

Topics

Resources

Stars

21 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages