javatomcatsslsslexception

SSLException: Received fatal alert: internal_error (thrown under tomcat, but works fine in desktop)


When I apply that code in a desktop application:

 WebClient webClient = new WebClient();
 WebRequest wreq = new WebRequest( new URL (url), com.gargoylesoftware.htmlunit.HttpMethod.GET);
 HtmlPage p = (HtmlPage) webClient.getPage( wreq);

it works fine, I get an answer:

[Raw read]: length = 5
0000: 16 03 03 00 5D                                     ....]
[Raw read]: length = 93

(and then proceed with handshake)

But when I try to use exactly the same code within a web-application in a tomcat, it shows that error:

[Raw read]: length = 5
0000: 15 03 03 00 02                                     .....
[Raw read]: length = 2
0000: 02 50                                              .P
tt_20170131_142449, READ: TLSv1.2 Alert, length = 2
tt_20170131_142449, RECV TLSv1.2 ALERT:  fatal, internal_error
tt_20170131_142449, called closeSocket()
tt_20170131_142449, handling exception: javax.net.ssl.SSLException: Received fatal alert: internal_error

TLS versions are the same. I tried some things usually suggested in that case, like webClient.getOptions().setUseInsecureSSL( false) and so on, but, as I said, that doesn't look like a protocol issue due to excatly the same code works perfectly while running without a tomcat. So where should I dig to find a solution?

Also there are different lenght of MD5 and SHA1 hashes:

[write] MD5 and SHA1 hashes: len = 161 <--- cause an exception

[write] MD5 and SHA1 hashes: len = 213 <--- works fine


Solution

  • Solved by replacing httpclient-4.3.1.jar with 4.3.3 version.