Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Streaming][bugfix] handle TLS signalisation when TLS is disabled on client side #9494

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions agent/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,20 @@ func newDialer(servers ServerLocator, wrapper TLSWrapper) func(context.Context,
return nil, fmt.Errorf("TLS enabled but got nil TLS wrapper")
}

// Switch the connection into TLS mode
if _, err := conn.Write([]byte{byte(pool.RPCTLS)}); err != nil {
conn.Close()
return nil, err
}

// Wrap the connection in a TLS client
// Wrap the connection in a TLS client, return same conn if TLS disabled
pierresouchay marked this conversation as resolved.
Show resolved Hide resolved
tlsConn, err := wrapper(server.Datacenter, conn)
if err != nil {
conn.Close()
return nil, err
}
conn = tlsConn
if tlsConn != conn {
// If connection is upgraded to TLS, mark the stream as RPCTLS
if _, err := conn.Write([]byte{byte(pool.RPCTLS)}); err != nil {
conn.Close()
return nil, err
}
conn = tlsConn
}
}

_, err = conn.Write([]byte{pool.RPCGRPC})
Expand Down