I would like to know the process of creation and verification of JWT signature using public and private keys in spring boot security.
I am trying to validate JWT token using HMAC algorithm. I am building JWT with hardcoded secret "MYSECRET".
Jwts.builder()
.setClaims(claims)
.setSubject(subject)
.setAudience(audience)
.setIssuedAt(createdDate)
.setExpiration(expirationDate)
.signWith(SignatureAlgorithm.HS512, "MYSECRET")
.compact()
For parsing the code is as follows
Jwts.parser()
.setSigningKey("MYSECRET")
.parseClaimsJws(token)
.getBody();
Instead of using signing key as "MYSECRET", I would like to make use of public and private keys
jjwt
library, that can be used with spring or not. Alternatively spring has its own JWT implementation. Do you want to adapt your code to use a key pair or re-implement all? - pedrofb