2

I have a web application that connects to a https site. For that I have to install the certificate in the cacerts in lib/security folder. I would like to create a truststore and place it within the application and while connecting to the other site make the app refer to this truststore so that when the application is moved the certificates move with it.

The way I connect to the https site is using a form post. How do I go about doing this. Also, when doing a form post rather than using a HttpsURLConnection, how to configure to look into custom truststore instead of cacerts.

2 Answers 2

2

The easiest way is to set a system property when launching the java process: -Djavax.net.ssl.trustStore=...

This is used by the default TrustManager, as described in http://docs.oracle.com/javase/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#X509TrustManager

Alternatively, override the TrustManager as described in the next paragraph in the same document.

Sign up to request clarification or add additional context in comments.

Comments

0

While the link in the other answer is a good reference, it refers to the already outdated JDK 1.5. Here is something more up to date, and the documentation has been improved as well:

https://docs.oracle.com/en/java/javase/18/security/java-secure-socket-extension-jsse-reference-guide.html#GUID-E1205974-3249-4E40-83C0-5F89C7375CF4

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.