Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8209973

ValidatorException thrown while connecting to https://google.com

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 11
    • security-libs
    • None

      ==================================SAMPLE CODE ==========================================
      import java.net.*;
      import java.io.*;

      public class HttpSample {
          public static void main(String[] args) throws Exception {
              URL test = new URL("https://google.com");
              URLConnection yc = test.openConnection();
              BufferedReader in = new BufferedReader(
                                      new InputStreamReader(
                                      yc.getInputStream()));
              String inputLine;

              while ((inputLine = in.readLine()) != null)
                  System.out.println(inputLine);
              in.close();
          }
      }

      ==================================SAMPLE CODE ==========================================

      Exception in thread "main" 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:128)
      at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:325)
      at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:268)
      at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:263)
      at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:642)
      at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.onCertificate(CertificateMessage.java:461)
      at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:361)
      at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:390)
      at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:445)
      at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422)
      at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:178)
      at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
      at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:877)
      at java.base/sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:810)
      at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:383)
      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.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1581)
      at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
      at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:245)
      at HttpSample.main(HttpSample.java:10)
      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 java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
      at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:290)
      at java.base/sun.security.validator.Validator.validate(Validator.java:264)
      at java.base/sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:321)
      at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:221)
      at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:129)
      at java.base/sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:626)
      ... 16 more
      Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
      at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
      at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
      at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)
      at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
      ... 22 more

            Unassigned Unassigned
            arajkumar Arunprasad Rajkumar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: