During developing of system sometimes there is need to use HTTPS connection to the client. However at stagging environment most probably there will be no HTTPS available or certificates are not properly signed.
Working in Java with no verification check of certificate
At first step there is possibility to add in Java code disabling of certificate validation. However this option should be used only during development mode. So finally at production certificate should be verified.
To achieve that there is possibility to do that in code. Sample code may look like:
Where class used will be:
So just change isCert to true at production, for example using properties.
Add Certificate in linux
When you will have a valid certificate, then just change flag isCert to true. In linux your certificate has to be added to know certificated in java. At first make sure that certificate is in PEM format. It should look like:
Next copy certificate to server in example to /root directory and add it to java.
Default password that you will be asked for is: changeit
In case that you don’t know where java is located you may look for it using:
or using any other method.
Remember to use at production environment always trusted certificates.
Posted in: Simple How To