blob: 5c9c840c80e830e31699e3e60aac357950de980b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// sign
package ses
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
"github.com/goamz/goamz/aws"
"time"
)
const (
AMZ_DATE_STYLE = "Mon, 02 Jan 2006 15:04:05 -0700"
)
// Sign SES request as dictated by Amazon's Version 3 signature method.
func sign(auth aws.Auth, method string, headers map[string][]string) {
date := time.Now().UTC().Format(AMZ_DATE_STYLE)
h := hmac.New(sha256.New, []byte(auth.SecretKey))
h.Write([]byte(date))
signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
authHeader := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s", auth.AccessKey, signature)
headers["Date"] = []string{date}
headers["X-Amzn-Authorization"] = []string{authHeader}
}
|