javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Couldn't find trusted certificate
Expand|Select|Wrap|Line Numbers
- 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();
- }
Changing the HttpURLConnection object to HttpsURLConnection throws up a 'java.lang.ClassCastException' error coz its an abstract class.. Any ideas? Thanks a lot