[TIL] JWT에서 signWith에서의 문제

SoDEV·2024년 6월 1일

스프링 부트

목록 보기
3/18
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

java.lang.IllegalArgumentException: Base64-encoded key bytes may only be specified for HMAC signatures.  If using RSA or Elliptic Curve, use the signWith(SignatureAlgorithm, Key) method instead.

해결방법 "HS"로 된 알고리즘을 사용하여야한다.

다음과 같이 HS256을 주어야하는데 ES256을 주었더니 에러가 났다.

hs256과 es256차이가 궁금해져서 구글링을 해보았다.
HS256 (HMAC SHA256) : 해싱을 이용한 대칭키 방식이다. privatekey로 복호화 서명을 검증한다.
RS256 (RSA + SHA256) : 공개키를 이용하는 암호화 방식이다. message를 sha256알고리즘으로 해싱 -> private key로 서명

참고로

Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

같은 경우 구글링을 해보니 경고문구일뿐 무시해도 된다고 한다.
보통은 인텔리제이 환경에서 세팅설정을 바꿔주면 경고가 해제된다고 한다.

Settings->Build,Excution,Deployment->Debugger->Async Stack Traces->Instrumenting agent(requires debugger restart)체크박스를 해제해주면 된다.

profile
비가 와도 눈이 와도 파도를 향해서! 🌊🐢

0개의 댓글