File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Question about server trusted certificates" Watch "Question about server trusted certificates" New topic

Question about server trusted certificates

Sha Mont

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();

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

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


Sha Mont
I agree. Here's the link:
subject: Question about server trusted certificates
It's not a secret anymore!