Я пытаюсь загрузить содержимое https-url в Java, но когда я получу эту ошибку.Java: HttpsUrlConnection - Не удалось создать путь PKIX
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Я был в состоянии сделать соединение HTTPS для других защищенных услуг, но не один я пытаюсь ударить прямо сейчас. Сервер является внутренним для нас и имеет сертификат Godaddy. Это может быть проблема?
public class DataRegressionTest {
private static String urlString = "https://somedomain.com/GetData";
public static void main(String[] args) throws Exception {
URL url = new URL(urlString);
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
String urlContent = StreamUtils.urlConnectionToUrlContent(httpsURLConnection);
JsonNode jsonNode = JsonUtils.jsonToTree(urlContent);
System.out.println(jsonNode);
}
}
Как исправить это?
Вот более полный трассировки стека происходит
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
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:563)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
Ваша догадка прямо на. Это похоже на что-то, что GoDaddy просто не нашел. Их технология SSL подведена. http://support.godaddy.com/groups/ssl-certificates/forum/topic/ssl-cert-not-recognized-by-java/ –