Skip to content

Commit

Permalink
SNOW-1869750 add check for empty private key before trying to generat…
Browse files Browse the repository at this point in the history
…e JWT from it (#1285)
  • Loading branch information
sfc-gh-dszmolka authored Jan 16, 2025
1 parent 1663004 commit 7f77aea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"crypto/x509"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7f77aea

Please sign in to comment.