From 5f097fed1ef4224eea3e079c1a109cc11bd26653 Mon Sep 17 00:00:00 2001 From: sfc-gh-dszmolka Date: Tue, 31 Dec 2024 11:30:15 +0100 Subject: [PATCH] SNOW-1869750 add check for empty private key before trying to generate JWT from it --- auth.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/auth.go b/auth.go index 3458085f1..f473471ef 100644 --- a/auth.go +++ b/auth.go @@ -8,6 +8,7 @@ import ( "crypto/x509" "encoding/base64" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -479,6 +480,9 @@ func createRequestBody(sc *snowflakeConn, sessionParameters map[string]interface // Generate a JWT token in string given the configuration func prepareJWTToken(config *Config) (string, error) { + if config.PrivateKey == nil { + return "", errors.New("trying to use keypair authentication, but PrivateKey was not provided in the driver config") + } pubBytes, err := x509.MarshalPKIXPublicKey(config.PrivateKey.Public()) if err != nil { return "", err