Skip to content

Commit 7f77aea

Browse files
SNOW-1869750 add check for empty private key before trying to generate JWT from it (#1285)
1 parent 1663004 commit 7f77aea

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

auth.go

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"crypto/x509"
99
"encoding/base64"
1010
"encoding/json"
11+
"errors"
1112
"fmt"
1213
"io"
1314
"net/http"
@@ -479,6 +480,9 @@ func createRequestBody(sc *snowflakeConn, sessionParameters map[string]interface
479480

480481
// Generate a JWT token in string given the configuration
481482
func prepareJWTToken(config *Config) (string, error) {
483+
if config.PrivateKey == nil {
484+
return "", errors.New("trying to use keypair authentication, but PrivateKey was not provided in the driver config")
485+
}
482486
pubBytes, err := x509.MarshalPKIXPublicKey(config.PrivateKey.Public())
483487
if err != nil {
484488
return "", err

0 commit comments

Comments
 (0)