From 5881f58af573346eb0c25945a433bf9859191ac5 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Sun, 4 Jul 2021 17:13:28 +0100 Subject: Check and log more possible errors --- pkg/twilio/filter.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/twilio') diff --git a/pkg/twilio/filter.go b/pkg/twilio/filter.go index 90e84cc..48e92ef 100644 --- a/pkg/twilio/filter.go +++ b/pkg/twilio/filter.go @@ -8,6 +8,7 @@ import ( "crypto/sha1" "encoding/base64" "errors" + "fmt" "log" "net/http" "sort" @@ -55,7 +56,9 @@ func (th *Filter) CheckRequestSignature(r *http.Request) error { } s := r.URL.String() + strings.Join(parts, "") h := hmac.New(sha1.New, th.AuthToken) - h.Write([]byte(s)) + if _, err := h.Write([]byte(s)); err != nil { + return fmt.Errorf("failed to write bytes to calculate signature: %s", err) + } ourSig := h.Sum(nil) if !hmac.Equal(reqSig, ourSig) { -- cgit v1.2.3-70-g09d2