Friday 8 January 2010

Importing self signed certificate into Java's cacerts keystore

Symptoms

  •  Getting an exception:
    javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
Possible cause of problem
  • Self-signed SSL certificate is used on remote server.

Possible solution
  1. Open remote page with Firefox. You should see something like a warning page.
  2. Click on "I Understand the Risks". You should really understand them.
  3. Click "Add Exception".
  4. Click "View" to view certificate.
  5. Go to "Details" tab and click "Export".
  6. Save certificate as X.509 Certificate (PEM) somewhere to your file system
  7. Don't forget to click "Confirm Security Exception" in Firefox.
  8. Execute command: keytool -keystore $JAVA_HOME/jre/lib/security/cacerts -import -file /path/to/cert.cer
  9. When you are prompted for a password and you haven't changed it, use the default: changeit
References

No comments:

Post a Comment