restlet / restlet-framework-java

The first REST API framework for Java
https://restlet.talend.com
Other
650 stars 284 forks source link

Android restlet SSL server: exception after all prefilled pool connections were used once #1320

Closed Oodie closed 5 months ago

Oodie commented 6 years ago

I can only establish a certain amount of connections, seems like if a pooled connection is used again, the connection somehow gets corrupted (or something with the underlying ssl engine).

I can reproduce this issue using Python with requests module, separate get requests in a loop, no sessions.

In the end I get a "javax.net.ssl.SSLProtocolException: Received message has bad padding" exception, exactly during the first request exceeding "initialConnections" count (default is 100).

If I try to set "pooledConnections" to false, that doesn't work either (directly throws an "W/SocketClient: write error (Broken pipe)" error).

Server parameters are set like this:

        parameters.add("sslProtocol","TLSv1.2");
        parameters.add("keyManagerAlgorithm", KeyManagerFactory.getDefaultAlgorithm());
        parameters.add("trustManagerAlgorithm", TrustManagerFactory.getDefaultAlgorithm());

        String strongCiphers =
                " TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"
                        + " TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
                        + " TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
                        + " TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256"
                        + " TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
                        + " TLS_RSA_WITH_AES_256_CBC_SHA"
                        + " TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA"
                        + " TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA"
                        + " TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA"
                        + " TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA"
                        + " TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA";

        parameters.add("enabledCipherSuites", strongCiphers);

Any ideas, or is something wrong with the server configuration?

Complete stack trace:

org.restlet.ext.nio.internal.connection.Connection onError WARNING: Received message has bad padding, stacktrace: [Ljava.lang.StackTraceElement;@41af1c78 javax.net.ssl.SSLProtocolException: Received message has bad padding at com.android.org.conscrypt.ConnectionStateTLS.decrypt(ConnectionStateTLS.java:310) at com.android.org.conscrypt.ConnectionState.decrypt(ConnectionState.java:132) at com.android.org.conscrypt.SSLRecordProtocol.unwrap(SSLRecordProtocol.java:382) at com.android.org.conscrypt.SSLEngineImpl.unwrap(SSLEngineImpl.java:463) at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:383) at org.restlet.ext.nio.internal.channel.ReadableSslChannel.onDrain(ReadableSslChannel.java:109) at org.restlet.ext.nio.internal.buffer.Buffer.process(Buffer.java:549) at org.restlet.ext.nio.internal.channel.ReadableBufferedChannel.read(ReadableBufferedChannel.java:171) at org.restlet.ext.nio.internal.buffer.Buffer.fill(Buffer.java:387) at org.restlet.ext.nio.internal.way.InboundWay.onFill(InboundWay.java:264) at org.restlet.ext.nio.internal.buffer.Buffer.process(Buffer.java:593) at org.restlet.ext.nio.internal.way.Way.processIoBuffer(Way.java:498) at org.restlet.ext.nio.internal.way.InboundWay.processIoBuffer(InboundWay.java:353) at org.restlet.ext.nio.internal.way.Way.onSelected(Way.java:451) at org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:316) at org.restlet.ext.nio.internal.connection.Connection.onSelected(Connection.java:611) at org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:316) at org.restlet.ext.nio.internal.controller.ConnectionController.onSelected(ConnectionController.java:215) at org.restlet.ext.nio.internal.controller.ServerConnectionController.onSelected(ServerConnectionController.java:109) at org.restlet.ext.nio.internal.controller.ConnectionController.selectKeys(ConnectionController.java:303) at org.restlet.ext.nio.internal.controller.ConnectionController.doRun(ConnectionController.java:166) at org.restlet.ext.nio.internal.controller.Controller.run(Controller.java:152) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841)

jlouvel commented 5 months ago

Closing as extension NIO has been removed in 2,5.