This repository has been archived by the owner on May 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 996
key is of invalid type, []byte('key') - not working. Hello from 2021... #452
Comments
SigningMethodES256 secret key must be an ecdsa.PrivateKey struct
|
try jwt.SigningMethodES256 => jwt.SigningMethodHS256 |
This is how I was able to solve the "key is invalid" error for ES256 encryption: ` privateKey := "YOU-PRIVATE-KEY"
|
@zsmhub is correct. HS256 can take a simple string input as secret. However, the ES256 expects a parsed secret key. As ECDSA is used with SHA in this case, it requests a string parsed in ECDSA Private Key format. This can be done as @mattlopez4011 mentioned with x509.ParsePKCS8PrivateKey. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
`token := jwt.NewWithClaims(jwt.SigningMethodES256, &tokenClaims{
jwt.StandardClaims {
ExpiresAt: time.Now().Add(tockenTTL).Unix(),
IssuedAt: time.Now().Unix(),
},
user.ID,
})
Originally posted by @yongDataScince in #65 (comment)
The text was updated successfully, but these errors were encountered: