Open ArtyomKravchenko opened 7 years ago
@ArtyomKravchenko Maybe you could create a pull request so we could all benefit from your changes?
@ArtyomKravchenko It would be useful if you share your code using org.apache.http.impl.client.HttpClientBuilder
instead o DefaultHttpClient
, because I got this same problem.
groovyx.net.http.RESTClient (inherited of groovyx.net.http.HTTPBuilder) uses deprecated API from org.apache.httpcomponents:httpclient lib - see HTTPBuilder.createClient(HttpParams param) method. It creates DefaultHttpClient which are deprecated in latest httpclient releases.
Such API (like DefaultHttpClient and other) has a several bugs related to SSL connection like: https://issues.apache.org/jira/browse/HTTPCLIENT-1726 JDK issue also applicable for httpclient I think: https://bugs.openjdk.java.net/browse/JDK-8144566
I believe that issue #68 SSL/TLS authentication has the same cause.
In my testing I got exception: Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error at sun.security.ssl.Alerts.getSSLException(Alerts.java:208) at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:543) at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:409) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177) at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:882) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:434) at groovyx.net.http.HTTPBuilder.request(HTTPBuilder.java:383) at groovyx.net.http.HTTPBuilder$request.call(Unknown Source)
I have rewritten single HTTPBuilder.createClient(HttpParams param) method for mine anonymous RESTClient instance: use org.apache.http.impl.client.HttpClientBuilder instead of deprecated DefaultHttpClient (as proposed in httpclient docs) and it solve the problem.
Dear developers, It will be fine to update httpclient dependency inside http-builder and use actual api instead of deprecated one.