https://github.com/kalloc/dkim
Golang DKIM Verifier
https://github.com/kalloc/dkim
dkim dkim-verifier go
Last synced: 5 months ago
JSON representation
Golang DKIM Verifier
- Host: GitHub
- URL: https://github.com/kalloc/dkim
- Owner: kalloc
- Created: 2015-01-05T01:01:40.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-02T19:56:47.000Z (over 8 years ago)
- Last Synced: 2025-03-30T23:05:34.525Z (6 months ago)
- Topics: dkim, dkim-verifier, go
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 21
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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?
```go
package mainimport (
"bufio"
"flag"
"fmt"
"os""github.com/kalloc/dkim"
)// ./test path/to/emls/*.eml
func main() {
var (
filename string
fp *os.File
err error
dk *dkim.DKIM
)flag.Parse()
for _, filename = range flag.Args() {
fmt.Printf("Check: %s — ", filename)
if fp, err = os.Open(filename); err != nil {
fmt.Printf("ERR-WRONG_FILE")
} else if dk, _ = dkim.ParseEml(bufio.NewReader(fp)); dk == nil {
fmt.Printf("ERR-DKIM_NOT_FOUND")
} else if _, err = dk.GetPublicKey(); err != nil {
fmt.Printf("ERR-DKIM_PK_NOT_FOUND")
} else if dk.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")
}
}
```