Support for TLS/plaintext Port Unification
See original GitHub issueIs your feature request related to a problem?
While trying to work with TLS, I was scanning through the current server setup. The NettyServerBuilder configures the port to be TLS or plaintext based on the presence or absence of SslContext
, correspondingly.
https://github.com/grpc/grpc-java/blob/012dbaf5be3fb0d532d977d288a0e42a58f30a7c/netty/src/main/java/io/grpc/netty/NettyServerBuilder.java#L352-L364
Resulting in a very little flexibility for the users to customize the port. Specifically, I was trying to see if we can accept both TLS & non-TLS connections on the same port without the need for creating a duplicate port. Netty demonstrates this through the doc.
Describe the solution you’d like
Approach1
Explicit public interface in NettyServerBuilder
for enabling/disabling/multiplexing TLS.
We could follow a similar approach of spiffing the initial bytes & dynamically configuring TLS.
Approach2 A public interface for adding child handlers to customize the connections. https://github.com/grpc/grpc-java/blob/012dbaf5be3fb0d532d977d288a0e42a58f30a7c/netty/src/main/java/io/grpc/netty/NettyServer.java#L228
Additional context
Relevant thread in stackoverflow: https://stackoverflow.com/questions/71484231/port-unification-in-grpc-java
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@ejona86 Currently working on a local POC to add a custom
ProtocolNegotiator
using theInternalProtocolNegotiator.ProtocolNegotiator
interface.And multiplexing the handlers:
InternalProtocolNegotiators.serverPlaintext().newHandler(grpcHttp2ConnectionHandler)
InternalProtocolNegotiators.serverTls(sslContext).newHandler(grpcHttp2ConnectionHandler)
I’d be happy to raise a PR once my experiment goes through.
Yes, I was able to get it working. The basic idea remains the same