2013-12-06 2 views
0

Я пытаюсь загрузить содержимое 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) 

ответ

1

Это исключение, если сертификат является недействительным. Если вы откроете URL-адрес с помощью браузера (Mozilla Firefox будет лучше всего подходит для этого теста, IE и Chrome с помощью сертификатов с сервера Active Directory в домене Windows), то он отображается как действительный?

Если нет (что я думаю), вам придется загрузить сертификат и добавить его в JVM.

+0

Ваша догадка прямо на. Это похоже на что-то, что GoDaddy просто не нашел. Их технология SSL подведена. http://support.godaddy.com/groups/ssl-certificates/forum/topic/ssl-cert-not-recognized-by-java/ –

Смежные вопросы