SecretKey algorithm did not equal one of the three required JCA
See original GitHub issueHi there,
We have struggled for over 2 hours to get this library to work (for a such a simple task (JWT) as to generate a simple JWT). Not a good start!
We end up figuring out the final problem to be this exception:
SecretKey algorithm did not equal one of the three required JCA algorithm names of HmacSHA256, HmacSHA384, or HmacSHA512.
The collection PREFERRED_HMAC_ALGS
has jcaName
s internally as HmacSHA256
etc. using camelcase. However when we generate a key using the library:
val key = Keys.secretKeyFor(SignatureAlgorithm.HS256)
The internal jcaName generated in the key is HMACSHA256
, all uppercase. The method SignatureAlgorithm()
throws an exception [here] https://github.com/jwtk/jjwt/blob/1839ebf5e8004336b018c9923bd09ee7deebdf39/api/src/main/java/io/jsonwebtoken/SignatureAlgorithm.java#L560
Are we doing something wrong? It can’t be this library has such a stupid string comparison bug and nobody else has notice it?!
We are using the version 0.9.0
from master
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:33 (22 by maintainers)
Top GitHub Comments
Released in 0.10.4. Please allow 30 minutes to propagate to Maven Central.
P.S. I’m cutting a 0.10.3 release tonight so you shouldn’t see this issue (since the assertion will be on key lengths only). Your engineer should be able to try tomorrow with the new 0.10.3 release and have it work out. If not, don’t worry - I’m happy to help and we’ll get you guys up and running asap. 😃