java.security.cert.CertificateException: Couldn't find trusted certificate
I had the following code to connect to a site on a server. It worked fine, now the server is using https, which causes the error:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Couldn't find trusted certificate.
Code:
java.util.Properties propSy = System.getProperties();
propSy.put("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
System.setProperties(propSy);
java.security.Security.insertProviderAt(new sun.security.provider.Sun(),2);
java.security.Security.addProvider(new sun.security.provider.Sun());
java.security.Security.insertProviderAt(new com.sun.net.ssl.internal.ssl.Provider(),1);
System.setProperty("javax.net.ssl.trustStore", "keystore_filename");
java.security.Provider myprov = java.security.Security.getProvider("SunJSSE");
HttpsURLConnection c;
try {
URL url = new URL ( rptUrl );
c = (HttpsURLConnection)url.openConnection();
//set cache and request method settings
c.setUseCaches(false);
//set other headers
c.setRequestProperty ("Content-Type", "application/pdf");
//connect to the server..
c.connect();
}
Any ideas? Thanks a lot.
Felissa:p