Browse Source

upgrade go-dkim

tags/v2.5.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
4f9d406b93
4 changed files with 15 additions and 6 deletions
  1. 1
    1
      go.mod
  2. 2
    0
      go.sum
  3. 11
    4
      vendor/github.com/toorop/go-dkim/dkim.go
  4. 1
    1
      vendor/modules.txt

+ 1
- 1
go.mod View File

@@ -17,7 +17,7 @@ require (
17 17
 	github.com/oragono/go-ident v0.0.0-20200511222032-830550b1d775
18 18
 	github.com/stretchr/testify v1.4.0 // indirect
19 19
 	github.com/tidwall/buntdb v1.1.4
20
-	github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e
20
+	github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208
21 21
 	golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
22 22
 	golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f // indirect
23 23
 	golang.org/x/text v0.3.3

+ 2
- 0
go.sum View File

@@ -68,6 +68,8 @@ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 h1:Otn9S136ELckZ
68 68
 github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563/go.mod h1:mLqSmt7Dv/CNneF2wfcChfN1rvapyQr01LGKnKex0DQ=
69 69
 github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e h1:uZTp+hhFm+PCH0t0Px5oE+QYlVTwVJ+XKNQr7ct4Q7w=
70 70
 github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns=
71
+github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208 h1:PM5hJF7HVfNWmCjMdEfbuOBNXSVF2cMFGgQTPdKCbwM=
72
+github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208/go.mod h1:BzWtXXrXzZUvMacR0oF/fbDDgUPO8L36tDMmRAf14ns=
71 73
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
72 74
 golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073 h1:xMPOj6Pz6UipU1wXLkrtqpHbR0AVFnyPEQq/wRWz9lM=
73 75
 golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

+ 11
- 4
vendor/github.com/toorop/go-dkim/dkim.go View File

@@ -100,6 +100,7 @@ func NewSigOptions() SigOptions {
100 100
 // Sign signs an email
101 101
 func Sign(email *[]byte, options SigOptions) error {
102 102
 	var privateKey *rsa.PrivateKey
103
+	var err error
103 104
 
104 105
 	// PrivateKey
105 106
 	if len(options.PrivateKey) == 0 {
@@ -109,11 +110,17 @@ func Sign(email *[]byte, options SigOptions) error {
109 110
 	if d == nil {
110 111
 		return ErrCandNotParsePrivateKey
111 112
 	}
112
-	key, err := x509.ParsePKCS1PrivateKey(d.Bytes)
113
-	if err != nil {
114
-		return ErrCandNotParsePrivateKey
113
+
114
+	// try to parse it as PKCS1 otherwise try PKCS8
115
+	if key, err := x509.ParsePKCS1PrivateKey(d.Bytes); err != nil {
116
+		if key, err := x509.ParsePKCS8PrivateKey(d.Bytes); err != nil {
117
+			return ErrCandNotParsePrivateKey
118
+		} else {
119
+			privateKey = key.(*rsa.PrivateKey)
120
+		}
121
+	} else {
122
+		privateKey = key
115 123
 	}
116
-	privateKey = key
117 124
 
118 125
 	// Domain required
119 126
 	if options.Domain == "" {

+ 1
- 1
vendor/modules.txt View File

@@ -55,7 +55,7 @@ github.com/tidwall/rtree
55 55
 github.com/tidwall/rtree/base
56 56
 # github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563
57 57
 github.com/tidwall/tinyqueue
58
-# github.com/toorop/go-dkim v0.0.0-20200526084421-76378ae5207e
58
+# github.com/toorop/go-dkim v0.0.0-20201103131630-e1cd1a0a5208
59 59
 ## explicit
60 60
 github.com/toorop/go-dkim
61 61
 # golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a

Loading…
Cancel
Save