wood burning stoves 2.0*
The moose likes Web Services and the fly likes Question about server trusted certificates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Question about server trusted certificates" Watch "Question about server trusted certificates" New topic
Author

Question about server trusted certificates

Sha Mont
Greenhorn

Joined: Aug 02, 2012
Posts: 5
I have a class that accesses a web service through HTTPS. This class will be used by a separate application. While developing the class I created JUnit test cases for testing. These test cases invoke a connection method in the class which connects to the web service.

The web service documentation indicates that the trusted certificate for the server should be imported into a java keystore at a specific location/directory as other tools will expect it to be there.

Since this is not what I think of as the standard place for certs, cacerts, I added the following code to my class to point to the appropriate location:

Properties systemProps = System.getProperties();
systemProps.put("javax.net.ssl.trustStore","C:/VMware-Certs/keystorename");
systemProps.put("javax.net.ssl.keyStore","C:/VMware-Certs/keystorename");
systemProps.put("javax.net.ssl.keyStorePassword",keystorepass);
systemProps.put("javax.net.ssl.keyStoreType","JKS");
System.setProperties(systemProps);

The JUnit test cases run flawlessly.

When I added the class to the application, I received an error about not being able to find the certificate.

I contacted the developer for the application that will use my class and they said that I needed to add the certificate to the cacerts keystore.

Now the application works as well.

My question is this. Why do I need to add the certificate to cacerts if my class code sets system properties so that the certificate can be found before attempting to connect? Does the application somehow override my code for the certificate?

While everything is working fine, I would like to understand how this works.

Thanks in advance
Sha Mont
Greenhorn

Joined: Aug 02, 2012
Posts: 5
Wow, is there anyone here that can explain this to me?

Thanks

Sha Mont
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about server trusted certificates
 
Similar Threads
WLST over SSL
HTML/Post java.lang.classcastexception
problem calling a remote webservice [ Algo Error]
SOAP over HTTPS / SSL
WLST over SSL