Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

Java SSL

I am trying to use java.net.ssl to connect to a secure server, but i get the following error

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

I know this is happening because the server has a self signed certificate
how do i add a host/certificate to a "trusted list" so that this exception isnt thrown?

1 Solution
This article explain how to add your server (self signed certificate) to your client trusted list.
1. Export the self-signed certificate.
keytool -export -alias "alias name" -keystore "keyFile" -rfc -file "alias name".cer

2. Import the certificate into a new/your client truststore.
keytool -import -alias "alias name"cert -file "alias name".cer -keystore truststore

3. add the following codes to your client program.
System.setProperty("javax.net.ssl.trustStore", "truststore");
System.setProperty("javax.net.ssl.trustStorePassword", "trustword");

You can see this link for more details: http://publib.boulder.ibm.com/infocenter/cicstg60/topic/com.ibm.cicstg600.doc/ccllan0053.htm

Another solution is to use one of the anonymous cipher suite which enable secure channel without authenticating the sides
see: http://forum.java.sun.com/thread.jspa?threadID=317434&messageID=1284571

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now