I've updated jjwt to version 0.12.3. I use a keystore PKCS12 to sign jwt and validate it. But now I'm getting errror: JWS verification key must be either a SecretKey (for MAC algorithms) or a PublicKey (for Signature algorithms). Everything works fine on the version 0.9.1
private static Key getKey() throws Exception {
KeyStore keystore = KeyStore.getInstance("PKCS12");
keystore.load(GenerateValidateKey.class.getResourceAsStream("/test.p12"), "test".toCharArray());
Enumeration aliases = keystore.aliases();
String keyAlias = "";
while (aliases.hasMoreElements()) {
keyAlias = (String) aliases.nextElement();
}
return keystore.getKey(keyAlias, "test".toCharArray());
}
Map<String, Object> claims = new HashMap<>();
claims.put("aud", "test");
claims.put("sub", "test");
String token = Jwts.builder().signWith(SignatureAlgorithm.RS256, getKey())
.setSubject("test")
.setExpiration(Date.from(expiration.atStartOfDay(ZoneId.systemDefault()).toInstant()))
.setIssuedAt(Date.from(now.atStartOfDay(ZoneId.systemDefault()).toInstant()))
.setClaims(claims)
.compact();
Claims claims = Jwts.parser()
.setSigningKey(getKey())
.requireAudience("test")
.build()
.parseClaimsJws(token)
.getBody();
Can you try this: