Framework/Spring Boot

[Error] "The specified key byte array is 128 bits which is not secure enough for any JWT HMAC-SHA algorithm.

잔망루피 2022. 12. 9. 14:17
반응형
{
    "response": "error",
    "message": "로그인에 실패했습니다.",
    "data": "The specified key byte array is 128 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비트보다 커야한다.

256비트면 32바이트

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

 

 

# JWT Secret Key
spring.jwt.secret=happilyeverafterhappilyeverafter

applicaion.properties에서 위와 같이 32바이트 이상이 되도록 수정하고 해결!

 

 

 

👇 참고

https://www.rfc-editor.org/rfc/rfc7518#section-3.2

 

RFC 7518: JSON Web Algorithms (JWA)

 

www.rfc-editor.org

 

반응형