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