Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about server trusted certificates

 
Sha Mont
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, is there anyone here that can explain this to me?

Thanks

Sha Mont
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic