importing certificates in java

 

Here are a few points that I would like to remember (when I have to do this again).

 

  • Use IE (not firefox) and visit the secure site that you want to access from Java. 
  • Right click on the page and choose "Properties"
  • Click on "Certificates"
  • Choose Details
  • Choose "Copy To File"
  • Hit "Next"
  • Choose the default format "DER encoded binary X.509 (.CER)"
  • Save your file (ie c:/certs/myhost.cer)

Now open a command console window

  • cd to the "security" folder of the JRE that you want to use (ie C:\Program Files\Java\jre6\lib\security)
  • Run the following:  keytool -import -alias localhost -file c:\certs\myhost .cer -keystore cacerts

 

You should now be able to access that https site from java.

Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options