I\'m using Apache HttpComponents HttpClient(4.0.1) to make a HTTPS call, but I\'m this exception as the response:
javax.net.ssl.SSLPeerUnverifiedException: peer
The exception message
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
doesn't always indicate the root cause of the issue.
You may need to enable the SSL handshake debug by adding theJava VM parameter -Djavax.net.debug=ssl:handshake
.
Once you've added that you will get more helpful error messages.
If the remote server uses a certificate that is not trusted you will see the following error message:
javax.net.ssl.SSLHandshakeException:
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
If that is the case then the answer by @Abhishek will solve the issue.
as mentioned above either you import the certificate
keytool -import -alias XYZ -file XYZ.cer -keystore C:/Program~1/Java/jdk1.6.0_23/jre/lib/security/cacerts -storepass changeit
OR
use your own trust manager http://tech.chitgoks.com/2011/04/24/how-to-avoid-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated-problem-using-apache-httpclient/
Make sure that the server URL is supposed to use https instead of http. You can get this error trying to set up a secure connection to an http URL.
Any SSL connection issue can result in this error.
One of my solution is upgrade java from 6 to 8. Our problem is the server we meant to communicate is stop supporting TLS 1.0. And java 6 does not support upper version of TLS 1.0. After update Java (even without upgrade dropwizard) it works.