0

After reading the fix to this error:

Severe: 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

I did what the answer suggested. However the error is still there. To download the certificate I right clicked on the webpage I'm trying to make a request to and went through the steps in the screenshot below :

Downloading certificate

After using this command :

keytool -import -file <the cert file> -alias <some meaningful name> -keystore <path to cacerts file>

The certificate is indeed listed with :

keytool -list -keystore "%JAVA_HOME%/jre/lib/security/cacerts"

and the error appears when I do this:

public void getTopStream() {
    streamChannels.clear();
    String urlHitbox = "https://www.hitbox.tv/api/media/live/list?game=counter-strike-global-offensive&liveonly=true&limit=10&hiddenOnly=false&size=mid&showHidden=true";

    CloseableHttpClient hitboxHttpclient = HttpClients.createDefault();
    HttpGet hitboxHttpGet = new HttpGet(urlHitbox);
    try {       
        // hitbox.tv
        CloseableHttpResponse responseHitbox = hitboxHttpclient
                .execute(hitboxHttpGet);
        HttpEntity hitboxEntity = responseHitbox.getEntity();
        responseHitbox.close();
            }
        }

        // hitbox.tv
        if (hitboxEntity != null) {
            Scanner scanner = new Scanner(hitboxEntity.getContent());
            String strHitbox = "";
            while (scanner.hasNextLine()) {
                strHitbox = scanner.nextLine();
            }
            scanner.close();
            if (!strHitbox.equals("")) {
                hitboxTransformJSON(strHitbox);
            }
        }
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

Any idea of what's wrong ?

Community
  • 1
  • 1
Ced
  • 15,847
  • 14
  • 87
  • 146
  • Are you sure you're using that JRE? Are you sure www.hitbox.tv is really using an untrusted certificate? – user207421 Jul 31 '15 at 23:05
  • @EJP , thanks for your answer, Am I sure I'm using that JRE ? Well in Eclipse it is indeed the JDK that is listed in the jre runtime. But maybe glassfish use another ? Pardon my ignorance. As for hitbox.tv using a non trusted certificate, it is trusted in my webbrowser but I get the SslHandshakeException when I try to request via my web-app, so I'm assuming it's not trusted by the server. – Ced Aug 02 '15 at 19:28

0 Answers0