netty: only add gRPC negotiator once SSL is established

This commit is contained in:
Carl Mastrangelo 2018-01-25 11:51:24 -08:00 committed by GitHub
parent 36670c1fcd
commit 417765b814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -611,7 +611,7 @@ public final class ProtocolNegotiators {
BufferUntilTlsNegotiatedHandler( BufferUntilTlsNegotiatedHandler(
ChannelHandler bootstrapHandler, GrpcHttp2ConnectionHandler grpcHandler) { ChannelHandler bootstrapHandler, GrpcHttp2ConnectionHandler grpcHandler) {
super(bootstrapHandler, grpcHandler); super(bootstrapHandler);
this.grpcHandler = grpcHandler; this.grpcHandler = grpcHandler;
} }
@ -630,6 +630,10 @@ public final class ProtocolNegotiators {
// Successfully negotiated the protocol. // Successfully negotiated the protocol.
logSslEngineDetails(Level.FINER, ctx, "TLS negotiation succeeded.", null); logSslEngineDetails(Level.FINER, ctx, "TLS negotiation succeeded.", null);
// Wait until negotiation is complete to add gRPC. If added too early, HTTP/2 writes
// will fail before we see the userEvent, and the channel is closed down prematurely.
ctx.pipeline().addBefore(ctx.name(), null, grpcHandler);
// Successfully negotiated the protocol. // Successfully negotiated the protocol.
// Notify about completion and pass down SSLSession in attributes. // Notify about completion and pass down SSLSession in attributes.
grpcHandler.handleProtocolNegotiationCompleted( grpcHandler.handleProtocolNegotiationCompleted(