1

I have followed all instructions on https://github.com/escline/InstallCert

and the main method worked for the first time, but when I started the main method second time it again started throwing same error:

Exception in thread "main" org.kohsuke.github.HttpException: Server returned HTTP response code: -1, message: 'null' for URL: https://api.github.com/user
    at org.kohsuke.github.Requester.parse(Requester.java:840)
    at org.kohsuke.github.Requester.parse(Requester.java:782)
    at org.kohsuke.github.Requester._to(Requester.java:393)
    at org.kohsuke.github.Requester.to(Requester.java:353)
    at org.kohsuke.github.GitHub.getMyself(GitHub.java:547)
    at org.kohsuke.github.GitHub.<init>(GitHub.java:168)
    at org.kohsuke.github.GitHubBuilder.build(GitHubBuilder.java:361)
    at org.kohsuke.github.GitHub.connectUsingOAuth(GitHub.java:300)
    at com.controller.TestMain.main(TestMain.java:29)
Caused by: 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:1946)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
    at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:310)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1640)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:223)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1570)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:352)
    at org.kohsuke.github.Requester.parse(Requester.java:790)
    ... 8 more
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 sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:450)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:317)
    at sun.security.validator.Validator.validate(Validator.java:262)
    at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:330)
    at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:227)
    at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)
    at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1622)
    ... 22 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:445)
    ... 28 more
Disconnected from the target VM, address: '127.0.0.1:50330', transport: 'socket'

Also I checked with this command keytool -list -keystore "%JAVA_HOME%/jre/lib/security/cacerts"

and I can see github.com, certificate already installed. Anything more I need to do?

Nagendra Singh
  • 577
  • 1
  • 7
  • 24
  • Is the java you are using the one in `%JAVA_HOME%`? This might sound stupid, but if you are running your program from IDE, different java might be used. (Intellij IDEA by default comes with it's own JDK and might use that to run programs, instead of java in `JAVA_HOME` directory) – Šimon Kocúrek Mar 28 '20 at 17:28
  • The [PKIX..] exception is due to missing certificates in the Java key-store. In case you are behind a corporate firewall, you usually need to install your company's certificates. You can use the browser to look up the certificates you need, see this : https://stackoverflow.com/questions/21076179/pkix-path-building-failed-and-unable-to-find-valid-certification-path-to-requ – Daniele Mar 28 '20 at 17:29
  • then, you can check if the certificates are installed correctly, by using a simple "SSL-poke" program. You can use that program to verify the connection towards, eg. google.com or github.com . See page https://gist.github.com/4ndrej/4547029 – Daniele Mar 28 '20 at 17:31
  • @ŠimonKocúrek I configured my IDE to use the JDK from same place – Nagendra Singh Mar 28 '20 at 17:34
  • @Daniele I got it from chrome browser directly and installed it and it worked now. – Nagendra Singh Mar 28 '20 at 17:40

0 Answers0