- goto https://url.you.want.to.open.https.connection.to url using internet explorer.
- in the bottom of internet explorer look for padlock icon, click on that icon, goto Details tab
- in Details tab click on “Copy to File…” button, it will open a “Certificate Export Wizard”, Click on Next button
- in “Select the format you want to use:” click on Base-64 encoded X.509 (.CER) radio button, then click on Next button
- give absolute path of the file name you want certifcate to export to, for example I put, C:\certificates\test.com-base64.cer
- Run following command from command prompt–
%JAVA_HOME%\jre\bin\keytool -v -import -trustcacerts -file <cer-file-path> -keystore <keystore-file-path>
keytool -v -import -trustcacerts -file c:\certificates\test.com-base64.cer -keystore c:\certificates\.keystore
Enter keystore password: topsecret
Certificate was added to keystore
Make sure c:\certificates\.keystore file not empty (if it exists), if its empty delete it. You can store multiple certificate in one keystore file, for that when you are importing certificate to keystore you need to provide alias for the certificate.
keytool -alias test -v -import -trustcacerts -file c:\certificates\test.com-base64.cer -keystore c:\certificates\.keystore
- Have following system properties set to your jvm–
- list all the keys is keystore
keytool -list -keystore c:\certificates\.keystore
For some reason Httpclient was still failing to executeMethod after all this.
was the reason for that, (I dont know why, probable bug in httpclient I was using)
then it worked.