Key is of invalid type

I am setting up security middleware in a GoLang API and seem to have everything set up correctly, but I am getting an error ‘key is of invalid type’.

I have confirmed that my Signing algorithm is RS256 and the middleware options are configured @ SigningMethod: jwt.SigningMethodRS256

I have a valid token…everything else in the middleware passes.

The entry point to this error in the middleware is the jwt.ParseRSAPrivateKeyFromPEM method.

I’ve isolated the error down inside the package github.com/dgrijalva/jwt-go/rsa.go Verify() on line :62 is the ErrInvalidKeyType that is getting thrown. All the params up to the this point seem solid and appropriate (eg m|signingString|signature|key) but this key.(*rsa.PublicKey) is failing…in my debugger (GoLand) I inspect *rsa and am given the response ‘could not find symbol value for rsa’…

if rsaKey, ok = key.(*rsa.PublicKey); !ok {
    return ErrInvalidKeyType
}

please note…if it’s not already too obvious…i’m noob to GoLang

Also on :: Key is of Invalid Type when parsing JWT Auth token in jwt-go - Stack Overflow

Hi @btschirhart,

Welcome to the Auth0 Community Forum!

You have confirmed that the signing algorithm in the dashboard is set correctly?

Thanks,
Dan