Purple Bobblehead Bunny

Backend/SPRINGBOOT

[SpringBoot] SpringBoot, JWT 오류 The signing key's size is 240 bits which is not secure enough for the HS256 algorithm

준영어린이 2022. 11. 14. 17:04

 

 

SpringBoot JWT 공부를 하다가 오류를 발견 했다....

 

 

오류 코드를 보면..

 

io.jsonwebtoken.security.WeakKeyException: The signing key's size is 240 bits which is not secure enough for the HS256 algorithm.  The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HS256 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 class's 'secretKeyFor(SignatureAlgorithm.HS256)' method to create a key guaranteed to be secure enough for HS256.  See https://tools.ietf.org/html/rfc7518#section-3.2 for more information.

 

첫 문장을 해석 해 보면

The signing key's size is 240 bits which is not secure enough for the HS256 algorithm.  The JWT JWA Specification (RFC 7518, Section 3.2) states that keys used with HS256 MUST have a size >= 256 bits (the key size must be greater than or equal to the hash output size). 

 

키가 240비트이고, HS256 알고리즘에 대해 안전하지 않다.. 라는 내용인데...

구글링을 해보니 JWT의 암호화 알고리즘을 HS256을 사용하는데 키 값 또한 256비트가 넘어야 한다.

라는 내용 이었다.

 

변수로 지정한 secretKey에 몇 글자 뚝딱 하니까 해결이 되었다!