I have a certificate(signed by a ca) added to my truststore, but when I try to access it via the following code, I get the exception, PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
public class ConnectHttps
{
public static void main(String[] argsd)
{
System.out.println("***************Https testing started **************");
try
{
URL u = new URL(
"https://my-server.com/my-webservices/data");
HttpsURLConnection http = (HttpsURLConnection) u.openConnection();
http.setAllowUserInteraction(true);
http.setRequestMethod("GET");
http.connect();
InputStream is = http.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder stringBuilder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
stringBuilder.append(line
+ "\n");
}
System.out.println(stringBuilder.toString());
System.out.println("***************Https testing completed **************");
}
catch (IOException e)
{
System.out.println("***************Https testing failed **************");
e.printStackTrace();
}
}
}
The certificate is valid and displays the data perfectly on google chrome and ie:
but not on mozilla firefox and my java client(above):
Please advise, what could be the problem.