You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2017/01/23 19:59:47 UTC

svn commit: r1779966 - /httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java

Author: olegk
Date: Mon Jan 23 19:59:46 2017
New Revision: 1779966

URL: http://svn.apache.org/viewvc?rev=1779966&view=rev
Log:
HTTPCORE-442: Non-blocking SSL sessions fail to decrypt buffered input data in some cases if closed by the opposite endpoint

Modified:
    httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java

Modified: httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java?rev=1779966&r1=1779965&r2=1779966&view=diff
==============================================================================
--- httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java (original)
+++ httpcomponents/httpcore/branches/4.4.x/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java Mon Jan 23 19:59:46 2017
@@ -470,19 +470,20 @@ public class SSLIOSession implements IOS
 
             try {
                 if (!inEncryptedBuf.hasRemaining() && result.getHandshakeStatus() == HandshakeStatus.NEED_UNWRAP) {
-                    throw new SSLException("Input buffer is full");
+                    throw new SSLException("Unable to complete SSL handshake");
                 }
-                if (result.getStatus() == Status.OK) {
+                final Status status = result.getStatus();
+                if (status == Status.OK) {
                     decrypted = true;
                 } else {
+                    if (status == Status.BUFFER_UNDERFLOW && this.endOfStream) {
+                        throw new SSLException("Unable to decrypt incoming data due to unexpected end of stream");
+                    }
                     break;
                 }
                 if (result.getHandshakeStatus() != HandshakeStatus.NOT_HANDSHAKING) {
                     break;
                 }
-                if (this.endOfStream) {
-                    break;
-                }
             } finally {
                 // Release inEncrypted if empty
                 if (this.inEncrypted.acquire().position() == 0) {