简体   繁体   中英

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated in Tomcat with Apache HttpClient

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM