0

I am trying to retrieve the HTML of the console logs of a Jenkins build using Jsoup connect method, but I am getting the following error

javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:320)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:263)
    at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:258)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:641)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:460)
    at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:360)
    at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:443)
    at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:421)
    at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:177)
    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
    at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:567)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:168)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:732)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:759)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:707)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:297)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:286)

I tried Document doc = Jsoup.connect(jobURL).validateTLSCertificates(false).get(); but my Intellij shows Cannot resolve method 'validateTLSCertificates' in 'Connection'

I am also not sure how can I pass my Jenkins username and usertoken (password) to retrieve the html. This is the code I have for connection. Not sure if it is correct.

String username = "username";
String password = "password";
String login = username + ":" + password;
String base64login = new String(Base64.encodeBase64(login.getBytes()));

doc = Jsoup.connect(jobURL)
           .header("Authorization", "Basic " + base64login)
           .get();

Can anyone help figure out the issue? Thanks!

  • Does this answer your question? [How to connect via HTTPS using Jsoup?](https://stackoverflow.com/questions/7744075/how-to-connect-via-https-using-jsoup) – fuat May 21 '20 at 23:41
  • @fuat Unfortunately it does not. The URL I am trying to access has a self-signed certificate as it is hosted in my company's intranet. – Ram Jashnani May 21 '20 at 23:47

0 Answers0