Results 1 to 5 of 5
- 07-01-2007, 05:47 PM #1
Member
- Join Date
- Jun 2007
- Posts
- 95
- Rep Power
- 0
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.
Any ideas? Thanks a lot.Java 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(); }
Felissa:p
- 07-06-2007, 06:23 AM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 111
- Rep Power
- 0
Perphas its something to do with this line
even when changed toJava Code:url = new URL("https", rptUrl, 443, "/");
I got the same error. Doing all the steps in the example but still setting the URL likeJava Code:url = new URL("https", rptUrl, "/");
EricJava Code:URL url = new URL ( rptUrl );
- 07-18-2007, 02:50 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 17
- Rep Power
- 0
HTTPS connection uses certificates. Certificates validation are done during HTTPS connection establish......so you need to install/use the trusted certificate......trusted certificate can be the certificate which send be server or the CA(certificate authority) which signs the certificates of the server....
- 07-18-2007, 02:52 PM #4
Member
- Join Date
- Jul 2007
- Posts
- 17
- Rep Power
- 0
we don't want to specify 443 port number because for https connection the default port is 443.....like http is 80 which we are not mentioning ...
- 08-10-2007, 10:09 PM #5
Member
- Join Date
- Aug 2007
- Posts
- 1
- Rep Power
- 0
This exception is thrown because you have not configured to accept the certificate of the website. The one-way SSL connections works in this way:
The web server hosting the URL in question will create a certificate and get it signed by a Certification Authority like Verisign.
when you try to connect to this URL, the server will provide this certificate.
If you trust this certificate then only the connection will be established.
Usually the CA assigned certificates wont throw this error as the identity of the server will be verified by the certificate authority, only self signed certificates will create problem. If they do then you have to add this certificate to your trusted certificate Keystore. Once you have added this certificate to the keystore this exception will not be thrown. To get the certificate use a web browser or ask the web server hosting the url to provide the certificate.
In your case you are using a custom keystore file,
"System.setProperty("javax.net.ssl.trustStore" , "keystore_filename");"
Please make sure you have imported the certificate to this keystore file.Last edited by abhishekjoshi; 08-10-2007 at 10:14 PM.
Similar Threads
-
java.security.cert.CertificateException: Couldn't find trusted certificate
By Marcus in forum Advanced JavaReplies: 3Last Post: 01-14-2010, 07:45 PM -
Java certificate
By Nick15 in forum Java CertificationReplies: 2Last Post: 11-12-2007, 06:02 AM -
java.security.AccessControlException
By cecily in forum Java AppletsReplies: 1Last Post: 08-06-2007, 02:49 AM -
difference between code based security and role based security
By boy22 in forum New To JavaReplies: 1Last Post: 07-23-2007, 11:59 PM -
Java cert exam samples
By orchid in forum New To JavaReplies: 5Last Post: 06-04-2007, 09:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks