로그인 토큰 정보를 가져오려고 하는데 다음과 같은 오류 메세지가 나옵니다.
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
인증서 부분에 대한 글이 있어 몇가지 해보았는데 안되네요…
자세히 설명좀 해주실수 있나요.ㅠㅠ.
- tomcat4.1
- java version “1.7.0_80”
==========================================
- 테스트 : https://test-kapi.kakao.com/test-ca-certificates
==========================================
Call(“GET”, “https://test-kapi.kakao.com/test-ca-certificates”);
public static String Call(String method, String reqURL) { String result = ""; try { String response = ""; URL url = new URL(reqURL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod(method); int responseCode = conn.getResponseCode(); System.out.println("=================="); System.out.println("responseCode : " + responseCode); System.out.println("reqURL : " + reqURL); System.out.println("method : " + method); System.out.println("=================="); InputStream stream = conn.getErrorStream(); if (stream != null) { try (Scanner scanner = new Scanner(stream)) { scanner.useDelimiter("\\Z"); response = scanner.next(); } catch(Exception e) {} System.out.println("error response : " + response); } BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line = ""; while ((line = br.readLine()) != null) { result += line; } System.out.println("response body : " + result); br.close(); } catch (IOException e) { System.out.println(e.getMessage()); } return result; }
==============================================
오류 메세지. 동일하게 발생
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
=======================================
2. curl -v https://test-kapi.kakao.com/test-ca-certificates
* About to connect() to test-kapi.kakao.com port 443 (#0) * Trying 203.133.166.34... connected * Connected to test-kapi.kakao.com (203.133.166.34) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * SSL connection using TLS_RSA_WITH_AES_256_CBC_SHA * Server certificate: * subject: CN=*.kakao.com,O=Kakao Corp.,L=Jeju-si,ST=Jeju-do,C=KR * start date: 9월 17 00:00:00 2021 GMT * expire date: 9월 30 23:59:59 2022 GMT * common name: *.kakao.com * issuer: CN=Thawte TLS RSA CA G1,OU=www.digicert.com,O=DigiCert Inc,C=US > GET /test-ca-certificates HTTP/1.1 > User-Agent: curl/7.19.7 (i386-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: test-kapi.kakao.com > Accept: */* > < HTTP/1.1 200 OK < Date: Mon, 10 Jan 2022 08:10:05 GMT < Content-Type: text/html;charset=utf-8 < Content-Length: 2 < Connection: keep-alive < Content-Language: en < * Connection #0 to host test-kapi.kakao.com left intact * Closing connection #0