jwt icon indicating copy to clipboard operation
jwt copied to clipboard

RS256 message too long for RSA public key size

Open lggomez opened this issue 3 years ago • 2 comments

Migrated from https://github.com/dgrijalva/jwt-go/issues/408:

shobhitsrivastava commented on Jun 11, 2020 •

I'm using a 256-bit private PEM to build a JWT with signing method RSA 256, similar to the example code:

signBytes, _ := ioutil.ReadFile(privKeyPath)
signKey, err := jwt.ParseRSAPrivateKeyFromPEM(signBytes)
token := jwt.NewWithClaims(jwt.SigningMethodRS256, middleware.CognitoAccessTokenClaim{
	CustomArray:  []string{"testString"},
	StandardClaims: jwt.StandardClaims{
	ExpiresAt: 1500,
	},
})
jwtString, err := token.SignedString(signKey)

When I try to sign the token, I'm getting the error crypto/rsa: message too long for RSA public key size. Does anyone know what could be causing this?

lggomez avatar Aug 03 '21 12:08 lggomez

ajoyac commented on Sep 17, 2020

Not sure if still open, but it seams its related to #213 (https://github.com/dgrijalva/jwt-go/issues/213) the rsa pem size it dosent have to be related to the signing method some how...

lggomez avatar Aug 03 '21 12:08 lggomez

I'll leave up to debate if we want to define this as a documentation issue or an enhancement

lggomez avatar Aug 03 '21 12:08 lggomez