Search code examples
javajava-securityjjwt

Using JJWT causes "java.lang.SecurityException: Invalid signature file digest for Manifest main attributes"


Why am I getting a "java.lang.SecurityException: Invalid signature file digest for Manifest main attributes" error when using Java JSON Web Token (JJWT)?

My code is (copied from https://github.com/jwtk/jjwt in its simplest form):

Key key = MacProvider.generateKey();

String compactJws = Jwts.builder()
    .setSubject("Joe")
    .signWith(SignatureAlgorithm.HS512, key)
    .compact();
return compactJws;

The exception stops at "Key key = MacProvider.generateKey();". And if I comment out the line, it will stop at the next line ("String compactJws =...")

Please help!


Solution

  • OK. I solved my own problem. It was the jar file was not properly compiled. I downloaded a jar from somewhere and it worked properly.