Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2007, 07:47 PM
Member
 
Join Date: Jun 2007
Posts: 95
Felissa is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-06-2007, 08:23 AM
Senior Member
 
Join Date: Jun 2007
Posts: 111
Eric is on a distinguished road
Perphas its something to do with this line
Code:
url = new URL("https", rptUrl, 443, "/");
even when changed to
Code:
url = new URL("https", rptUrl, "/");
I got the same error. Doing all the steps in the example but still setting the URL like
Code:
URL url = new URL ( rptUrl );
Eric
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-18-2007, 04:50 PM
Member
 
Join Date: Jul 2007
Posts: 17
sathish_2111 is on a distinguished road
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....
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-18-2007, 04:52 PM
Member
 
Join Date: Jul 2007
Posts: 17
sathish_2111 is on a distinguished road
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 ...
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-11-2007, 12:09 AM
Member
 
Join Date: Aug 2007
Posts: 1
abhishekjoshi is on a distinguished road
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-11-2007 at 12:14 AM.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java certificate Nick15 Professional Certification 2 11-12-2007 08:02 AM
java.security.AccessControlException cecily Java Applets 1 08-06-2007 04:49 AM
difference between code based security and role based security boy22 New To Java 1 07-24-2007 01:59 AM
java.security.cert.CertificateException: Couldn't find trusted certificate Marcus Advanced Java 2 07-03-2007 07:17 PM
Java cert exam samples orchid New To Java 5 06-04-2007 11:33 AM


All times are GMT +3. The time now is 02:05 PM.


VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org