From 2e07374681016d33ebf5901f8d9b51e9c9e51c2c Mon Sep 17 00:00:00 2001 From: Head of Product & Engineering Date: Sun, 5 Apr 2026 18:50:56 +0200 Subject: [PATCH] fix: tolerate literal \n in GHL_WEBHOOK_PUBLIC_KEY env var pem.Decode requires actual newlines. When a PEM key is pasted into a .env file it is commonly stored as a single line with \n literals. Normalise these before decoding so both formats work. Co-Authored-By: Paperclip --- internal/ghl/webhook.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/ghl/webhook.go b/internal/ghl/webhook.go index 26c207c..75e06f1 100644 --- a/internal/ghl/webhook.go +++ b/internal/ghl/webhook.go @@ -14,6 +14,7 @@ import ( "io" "log/slog" "net/http" + "strings" "sync" "time" @@ -230,7 +231,10 @@ func (h *WebhookHandler) HandleUninstall(w http.ResponseWriter, r *http.Request) } // parseRSAPublicKey decodes a PEM-encoded PKIX RSA public key. +// Tolerates literal \n sequences in the input (common when the key is stored +// as a single line in a .env file). func parseRSAPublicKey(pemStr string) (*rsa.PublicKey, error) { + pemStr = strings.ReplaceAll(pemStr, `\n`, "\n") block, _ := pem.Decode([]byte(pemStr)) if block == nil { return nil, fmt.Errorf("failed to decode PEM block")