[#160] No response to write if server is using SslHandler and client is not

- Make SslHandler close the connection immediately on SSLException or
  or NotSslRecordException
This commit is contained in:
Trustin Lee 2012-08-22 12:16:40 +09:00
parent 31a51b4937
commit 81305d87b4

View File

@ -372,9 +372,11 @@ public class SslHandler extends FrameDecoder
handshakeFuture.setFailure(e); handshakeFuture.setFailure(e);
fireExceptionCaught(ctx, e); fireExceptionCaught(ctx, e);
Channels.close(ctx, future(channel));
} }
} else { // Failed to initiate handshake. } else { // Failed to initiate handshake.
fireExceptionCaught(ctx, exception); fireExceptionCaught(ctx, exception);
Channels.close(ctx, future(channel));
} }
return handshakeFuture; return handshakeFuture;
@ -400,6 +402,7 @@ public class SslHandler extends FrameDecoder
return wrapNonAppData(ctx, channel); return wrapNonAppData(ctx, channel);
} catch (SSLException e) { } catch (SSLException e) {
fireExceptionCaught(ctx, e); fireExceptionCaught(ctx, e);
Channels.close(ctx, future(channel));
return failedFuture(channel, e); return failedFuture(channel, e);
} }
} }
@ -696,6 +699,7 @@ public class SslHandler extends FrameDecoder
NotSslRecordException e = new NotSslRecordException( NotSslRecordException e = new NotSslRecordException(
"not an SSL/TLS record: " + ChannelBuffers.hexDump(buffer)); "not an SSL/TLS record: " + ChannelBuffers.hexDump(buffer));
buffer.skipBytes(buffer.readableBytes()); buffer.skipBytes(buffer.readableBytes());
Channels.close(ctx, future(channel));
throw e; throw e;
} }
} }
@ -1208,6 +1212,7 @@ public class SslHandler extends FrameDecoder
} }
handshakeFuture.setFailure(cause); handshakeFuture.setFailure(cause);
Channels.close(ctx, future(channel));
} }
private void closeOutboundAndChannel( private void closeOutboundAndChannel(