web( jsp, servlet )/jsp

jwt 오류 ) hmac 알고리즘으로 인한 오류

읽히는 블로그 2024. 7. 16. 15:21

 

 

 

직접 암호화 키를 만들어서 적용시켜보려고 했는데 500에러가 나왔다.

 


에러 메시지는 아래와 같았다.

The specified key byte array is 104 bits which is not secure enough for any JWT HMAC-SHA algorithm. The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HMAC-SHA algorithms MUST have a size >= 256 bits (the key size must be greater than or equal to the hash output size).

Consider using the io.jsonwebtoken.security.Keys#secretKeyFor(SignatureAlgorithm) method to create a key guaranteed to be secure enough for your preferred HMAC-SHA algorithm. See https://tools.ietf.org/html/rfc7518#section-3.2 for more information.

 

HMAC-SHA 알고리즘은 KEY 사이즈가 256비트(32바이트)보다 커야한다.

영어는 한 글자당 1바이트이다.

(한글은 2바이트)

적어도 32글자 이상의 글이 있어야한다.