From 4f9d406b937a130e65dc7f6405c1bf38b1f299f1 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 8 Nov 2020 17:56:46 -0500 Subject: [PATCH] upgrade go-dkim --- go.mod | 2 +- go.sum | 2 ++ vendor/github.com/toorop/go-dkim/dkim.go | 15 +++++++++++---- vendor/modules.txt | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b01118a6..07b228f9 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775 github.com/stretchr/testify v1.4.0 // indirect github.com/tidwall/buntdb v1.1.4 - github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e + github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f // indirect golang.org/x/text v0.3.3 diff --git a/go.sum b/go.sum index e165499a..96bf877e 100644 --- a/go.sum +++ b/go.sum @@ -68,6 +68,8 @@ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 h1:Otn9S136ELckZ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563/go.mod h1:mLqSmt7Dv/CNneF2wfcChfN1rvapyQr01LGKnKex0DQ= github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e h1:uZTp+hhFm+PCH0t0Px5oE+QYlVTwVJ+XKNQr7ct4Q7w= github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns= +github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 h1:PM5hJF7HVfNWmCjMdEfbuOBNXSVF2cMFGgQTPdKCbwM= +github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= diff --git a/vendor/github.com/toorop/go-dkim/dkim.go b/vendor/github.com/toorop/go-dkim/dkim.go index ab893e31..3ed5c88f 100644 --- a/vendor/github.com/toorop/go-dkim/dkim.go +++ b/vendor/github.com/toorop/go-dkim/dkim.go @@ -100,6 +100,7 @@ func NewSigOptions() SigOptions { // Sign signs an email func Sign(email *[]byte, options SigOptions) error { var privateKey *rsa.PrivateKey + var err error // PrivateKey if len(options.PrivateKey) == 0 { @@ -109,11 +110,17 @@ func Sign(email *[]byte, options SigOptions) error { if d == nil { return ErrCandNotParsePrivateKey } - key, err := x509.ParsePKCS1PrivateKey(d.Bytes) - if err != nil { - return ErrCandNotParsePrivateKey + + // try to parse it as PKCS1 otherwise try PKCS8 + if key, err := x509.ParsePKCS1PrivateKey(d.Bytes); err != nil { + if key, err := x509.ParsePKCS8PrivateKey(d.Bytes); err != nil { + return ErrCandNotParsePrivateKey + } else { + privateKey = key.(*rsa.PrivateKey) + } + } else { + privateKey = key } - privateKey = key // Domain required if options.Domain == "" { diff --git a/vendor/modules.txt b/vendor/modules.txt index efeb27f7..ee54f3d6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -55,7 +55,7 @@ github.com/tidwall/rtree github.com/tidwall/rtree/base # github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 github.com/tidwall/tinyqueue -# github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e +# github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 ## explicit github.com/toorop/go-dkim # golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a