My code currently tries to ping a URL the user provide. It works fine with non-HTTPS websites. But if I try with something like: https://www.httpsnow.org/ I get an exception: Could not establish connection. Error is: 'sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target'
Code below:
try
{
long startTime = DateProvider.getCurrentTimeMillis();
huc = getConnection(url);
huc.setRequestMethod("GET");
huc.setConnectTimeout(10000);
huc.connect();
long endTime = DateProvider.getCurrentTimeMillis();
long processingTime = (endTime - startTime);
value = Long.toString(processingTime);
catch (IOException ioe)
{
processFailure("Could not establish connection. Error is: '" + ioe.getLocalizedMessage() + "'.");
}
What can I do to bypass the cert not being found code-wise?
Edit: I have looked at the solutions provided in the other thread. Implementation a TrustManager can open up to MITM attacks. But since I am only pinging the server, would that really affect me at all?