Skip to content

Instantly share code, notes, and snippets.

@geunho
Created March 11, 2019 01:50
Show Gist options
  • Select an option

  • Save geunho/a330e6f241a50fd6ba59a30ba60f36c4 to your computer and use it in GitHub Desktop.

Select an option

Save geunho/a330e6f241a50fd6ba59a30ba60f36c4 to your computer and use it in GitHub Desktop.
javax.net.ssl.SSLHandshakeException
#######################################################################################################################################################################################################################################
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
#######################################################################################################################################################################################################################################
# JDK에서 동작하는 consumer가 API provider 측의 SSL 인증서 경로를 제대로 찾지 못하거나 신뢰하지 못할 때 오류가 발생한다.
# 주로 오래된 버전의 HTTP 클라이언트 라이브러리를 사용하거나, JDK 버전이 낮은 경우 발생한다.
# consumer의 JRE keystore 경로에 provider의 인증서를 신뢰할 수 있는 인증서로 직접 추가하면 해결된다.
openssl s_client -connect $provider_internet_domain:443
# (1) 위 커맨드 입력 후
# ----BEGIN CERTIFICATE-----
# ~~~
# -----END CERTIFICATE------
# 까지의 내용만 cert 파일을 생성하여 저장
# e.g. provider.crt
# (2) JRE의 keystore에 저장
# -keystore 파라미터에는 실제로 어플리케이션이 동작하는 JAVA_HOME 경로를 입력해야 함
keytool -import -alias provider -keystore $JAVA_HOME/jre/lib/security/cacerts -file provider.crt
# (3) 비밀번호를 물어보는데, 별도 설정을 하지 않았다면 changeit 혹은 changeme 입력
# (4) 어플리케이션 서버 재시작
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment