본문 바로가기
Java

[Java] PKIX path building failed 문제 해결 방법

by 상후 2023. 11. 7.
728x90
반응형

 

sun.security.validator.ValidatorException: PKIX path building failed: 해결 방법

 

 

발생 원인

잘 사용하고 있던 서비스에서 갑자기 해당 에러를 내면서 문제가 발생했습니다.

해당 서비스는 타 사이트와의 연동을 진행하는 서비스였고, 구글링 해보니 SSL 인증서 문제라고 합니다.

https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ

 

SSL 인증서란 HTTPS(암호화된 연결)로 연결 시 상호 간 신뢰를 보증해 주는 인증서입니다.

간단히 생각하면 클라이언트 - 서버 간 인증된 연결을 위해 필요한 것이라고 생각하면 될 것 같습니다.

https://www.digicert.com/kr/what-is-an-ssl-certificate#What-is-an-SSL-Certificate 

 

 

해결 방법
내 시스템(클라이언트)에서 코드 변경이나, 환경이 변경된 적이 없고 상대(서버)측에서도 별 다른 인증서 교체 관련된 얘기를 듣지 못했으면, 내 시스템(클라이언트)의 인증서가 만료되었는지, 존재하는지 확인해 볼 필요가 있습니다.
필요한 인증서가 없다면, 해당 인증서를 다운/전달받아 내 시스템(클라이언트)에 등록하여 해결했습니다.

 

 

1. 연동하는 사이트에서 어떠한 인증서를 요구하는지 확인하자.

 

아래 사이트를 활용하여 연동이 안 되는 도메인의 요구 인증서 조건을 확인하자.

 

https://www.sslshopper.com/ssl-checker.html

 

SSL Checker

Use our fast SSL Checker to help you quickly diagnose problems with your SSL certificate installation. You can verify the SSL certificate on your web server to make sure it is correctly installed, valid, trusted and doesn't give any errors to any of your u

www.sslshopper.com

 

 

필자는 네이버 주소로 테스트를 진행했다.

digicert사의 GeoTrust RSA CA 2018이라는 인증서가 있어야 SSL 통신이 가능하다고 친절하게 알려준다.

 

 

 

2. 해당 인증서가 내 시스템에 있는지 확인하기

 

인증서의 종류를 확인했으면, 내 인증서 목록에 해당 인증서가 있는지 확인해야 한다.

GUI 방식으로 다운로드하여 쉽게 확인이 가능하다.

 

https://sourceforge.net/projects/portecle/

 

Portecle

Download Portecle for free. Portecle is a user friendly GUI application for creating, managing and examining key stores, keys, certificates, certificate requests, certificate revocation lists and more.

sourceforge.net

 

설치 후 File - Open Keystore File을 선택하여 설치된 자바 경로를 잡아주고 해당 인증서가 있는지 확인해 보자.

일반적으로 : JAVA_HOME/lib/security/cacerts 이다.

 

 

 

 

 

명령어로도 확인 가능하다.

경로 이동 : Program Files\Java\jdk1.8.0_291\jre\lib\security명령어 : keytool -keystore cacerts -list

 

https://sarc.io/index.php/miscellaneous/1455-java-cacerts-list-keytool

 

Java cacerts list 확인 (keytool)

Tech Note 정보 아주라 님이 작성하신 글입니다. 카테고리: [ Miscellaneous ] 게시됨: 05 March 2019 작성됨: 05 March 2019 최종 변경: 05 March 2019 조회수: 25738 1. 개요 자바의 cacerts에 들어있는 인증서 목록 확인

sarc.io

 

개인 컴퓨터가 아니라 서버 컴퓨터(리눅스)이고 자바 설치 경로를 모른다면, "export", "env" 명령어를 통해 환경변수를

확인할 수 있을 것이다.

 

 

 

해당 인증서가 없다면 인증서를 다운로드하여 추가해 주면 정상 동작한다.

 

https://www.digicert.com/kb/digicert-root-certificates.htm

 

DigiCert Root Certificates - Download & Test | DigiCert.com

Download DigiCert root and intermediate certificates DigiCert root certificates are widely trusted and used for issuing TLS Certificates to DigiCert customers—including educational, financial institutions, and government entities worldwide. DigiCert stro

www.digicert.com

 

 

 

인증서를 추가하는 방법은 아래의 사이트를 참고하여 진행했다.

 

https://signpen.net/2511886

 

자바 SSL 인증서 파일 등록하는 방법 정리 (Keytool, Portecle 활용) | 싸인펜의 Lifelog

자바 인증서 저장소에 직접 인증서를 추가해서 사용해야 하는 경우가 있습니다. Keytool, Portecle, SSL, 인증서, 자바

signpen.net

 

728x90
반응형

댓글