Skip to content

signWith for RSA512 #942

Closed Answered by lhazlewood
lost-jwt-users asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there!

The olderio.jsonwebtoken.SignatureAlgorithm enum (which is not extensible and did not allow for custom algorithm implementations) has been deprecated in favor of the newer (pluggable) io.jsonwebtoken.security.SignatureAlgorithm interface. Default (RFC-standard) implementations for that interface are available via the Jwts.SIG registry class:

https://github.com/jwtk/jjwt?tab=readme-ov-file#signaturealgorithm-override

With that, your example might look like this:

return Jwts.builder()
     .claims(claims)
    .subject(username)
    .issuedAt(issuedAt)
    .expiration(expiration.getTime())
    .signWith(getPrivateKey(), Jwts.SIG.RS512) // <---
    .compact();

I hope that helps! Fee…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lhazlewood
Comment options

Answer selected by lhazlewood
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants