I have created a jar for my JavaAppliaction.From this application I am connecting to servlet (I am passing name and password from swing to servlet) in the WebApplicaton(here I am just displaying name and password in the servlet).
I am passing data over SSL connection(Https). It is working fine in my system.But when I tried to run jar in another system I am getting “Connection refused error”.
Note:Running jar in another system which passes data over http connection is working fine.
I have gone through this link which suggested me to create a “jssecacerts” file and paste it in $JAVA_HOME/jre/lib/security folder of the “another system”. But I am still getting same error. Why is this not working??
One possible solution: Try importing the public certificate into java default keystore using.
keytool -importcert -trustcacerts -file "path-to-public-cert" -keystore JAVA_HOME/jre/lib/security/cacerts
it will ask for keystore password default keystore password is "changeit"
You can obtain the public cert by opening your URL in a web browser (e.g chrome) click on the icon at the start of URL -> click certificate information -> details tab -> click export
button.
A better approach will be:
- create a keystore using "keytool" available in JAVA_HOME/bin
- Import your server's public cert in this keystore.
- bundle the keystore with your app.
- make a bat / sh file to run your jar providing a parameter to java command -Djavax.net.ssl.trustStore=/path-to-your-keystore
So every time your app will start it will use this custom keystore. so you don't have to copy jssecacerts file on each system your run your app on.