Handling SecurityCertificateError exception in JAVA by adding security certificate using Keytools
To add the security certificate for https URL the following steps needs to be followed
- Take a backup of cacerts file in the following directory (This can be your default JRE directory also) C:\Program Files\IBM\SDP70\runtimes\base_v6\java\jre\lib\security\
- Save the security certificate in some location for ex c:\certificate.cer
- Go to Run type cmd
- Execute CD C:\Program Files\IBM\SDP70\runtimes\base_v6\java\jre\bin (This is the location of the JRE WebSphere uses, in other environments please navigate to the JRE BIN the application uses)
- Then execute the following command
Command
keytool -keystore "C:\Program Files\IBM\SDP70\runtimes\base_v6\java\jre \lib\security\cacerts" -import -file c:\certificate.cer -alias https://your-url.net
- It will ask for a password , enter changeit
- The security certificate will be added for the JRE
Now you can access the URL or access the webservice in the URL.