Skip to content

Commit 5759d46

Browse files
committed
use pkcs8 for rsa key
1 parent 2f37d7a commit 5759d46

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

functions/sign_string_rs256_pkcs8.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"crypto"
55
"crypto/rsa"
66
"crypto/sha256"
7-
"crypto/x509"
87
"encoding/base64"
98
"encoding/pem"
109
"errors"
@@ -35,9 +34,9 @@ func SignStringRS256PKCS8(existingHeaders map[string]string, args []string) (str
3534
// Parse the key, decrypting it if necessary
3635
//decryptedKey, err := pkcs8.ParsePKCS8PrivateKey(pemBlock.Bytes, []byte(passphrase))
3736
//decryptedKey, err := pkcs8.ParsePKCS8PrivateKey(pemBlock.Bytes)
38-
decryptedKey, err := x509.ParsePKCS8PrivateKey(pemBlock.Bytes)
37+
rsaKey, err := pkcs8.ParsePKCS8PrivateKeyRSA(pemBlock.Bytes)
3938

40-
if err != nil {
39+
/* if err != nil {
4140
return "", fmt.Errorf("error calling SignStringRS256PKCS8; unable to parse private key: %w", err)
4241
}
4342
@@ -47,7 +46,7 @@ func SignStringRS256PKCS8(existingHeaders map[string]string, args []string) (str
4746
rsaKey, ok = decryptedKey.(*rsa.PrivateKey)
4847
if !ok {
4948
return "", fmt.Errorf("error calling SignStringRS256PKCS8; key is not an RSA key")
50-
}
49+
} */
5150

5251
// Hash the string using SHA256
5352
hash := sha256.Sum256([]byte(stringToSign))

0 commit comments

Comments
 (0)