Reputation: 2282
When trying to use Apache HttpClient 4.x on OpenJDK 1.7.0 on Ubuntu inside Tomcat, I get an
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
exception. When using the same JDK with an basic HTTPS connection like
url = new URL(https_url);
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
it works and I get an connection and can read the content.
I have followed dozens of answers on stackoverflow, googled for some days and all suggest to import the cert into the keystore. I've done this, the problem persists. And it sounds strange to be my problem, as the basic connection with HttpsURLConnection works, but with HttpClient 4.x it doesn't.
Upvotes: 2
Views: 5918
Reputation: 2282
I found the solution last night. The problem seems to be that there were 2 different bouncy castles provider JARs in the classpath. Both drawn in by two different dependencies - one for JDK 1.4. After removing the 1.4 JDK bouncy castle jar the application worked.
Upvotes: 0