Fixes #3311 - Ability to serve HTTP and HTTPS from the same port.

Do not assume that the read from the network produced more than 1 byte.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2019-02-01 09:14:32 +01:00
parent 5061a5ca30
commit d9855fb1bc
1 changed files with 1 additions and 3 deletions

View File

@ -37,7 +37,6 @@ public class PlainOrSslConnectionFactory extends AbstractConnectionFactory
private static final Logger LOG = Log.getLogger(PlainOrSslConnection.class);
private static final int TLS_ALERT_FRAME_TYPE = 0x15;
private static final int TLS_HANDSHAKE_FRAME_TYPE = 0x16;
private static final int TLS_MAJOR_VERSION = 3;
private final SslConnectionFactory sslConnectionFactory;
private final String plainProtocol;
@ -71,8 +70,7 @@ public class PlainOrSslConnectionFactory extends AbstractConnectionFactory
protected boolean seemsTLS(ByteBuffer buffer)
{
int tlsFrameType = buffer.get(0) & 0xFF;
int tlsMajorVersion = buffer.get(1) & 0xFF;
return (tlsFrameType == TLS_HANDSHAKE_FRAME_TYPE || tlsFrameType == TLS_ALERT_FRAME_TYPE) && tlsMajorVersion == TLS_MAJOR_VERSION;
return tlsFrameType == TLS_HANDSHAKE_FRAME_TYPE || tlsFrameType == TLS_ALERT_FRAME_TYPE;
}
/**