본문 바로가기

JAVA 인증서 파일 추가 (JAVA certification import)

로컬 개발 중

https URL을 접속 하려고 하면 다음과 같은 에러가 발생할 수 있다.


Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.validator.PKIXValidator.doBuild(Unknown Source)

at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)

at sun.security.validator.Validator.validate(Unknown Source)

at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)

at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)

at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)

... 62 common frames omitted

Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

at sun.security.provider.certpath.SunCertPathBuilder.build(Unknown Source)

at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)

at java.security.cert.CertPathBuilder.build(Unknown Source)

... 68 common frames omitted


필자의 경우 Java에서 인증서를 인식하지 못하여 발생하는 오류로 확인되었다.


이 경우 Java keytool을 이용하여 인증서를 추가해주어야 한다.


윈도우 사용자의 경우로 방법을 기록하겠다. (리눅스의 경우에도 비슷하니 참고할 수 있다.)


1. 시작 -> 명령 프롬프트(cmd)를 실행한다.


2. cd ${자바 설치 경로}\jre\bin

자바 jre를 설치한 경로 안에 bin폴더로 이동하기 위해 해당 명령어를 실행한다.

(bin폴더 안에 keytool이 있기 때문에 이동하여 실행하고자 한다.)


3. keytool -import -file "${인증서 경로}\인증서명.crt" -keystore "${자바 설치 경로}\jre\lib\security\cacerts" -storepass "changeit"

명령어 복사하기

다음 명령어로 자바에 인증서를 추가할 수 있다.

-file 다음 파라미터는 인증서 위치이며

-keystore 다음 파라미터는 인증서를 추가하는 cacerts의 경로를 입력한다.

-storepass의 다음 파라미터는 기본적으로 저장되어 있는 패스워드를 입력하는데 changeit이 디폴트 패스워드이다.

다음 명령어 실행시 확인하는 문구가 나올 것이다.

예(영문버전인 경우 yes) 입력후 Enter를 진행하면 최종적으로 추가된다.


그리고 다시 https URL로 접속 해보자.

에러가 발생하지 않으면 인증서 문제였다는 것을 알 수 있다.


위의 설명이 이해가 되지 않는 경우 ibm에서 해당 에러로 인해 올린 해결 글을 참고해도 좋을 것 같다.


IBM 해결 글 바로가기







반응형
그리드형