Is there a way to configure NettyServerBuilder with SniHandler?
See original GitHub issueIs it possible to configure io.grpc.netty.NettyServerBuilder
with io.netty.handler.ssl.SniHandler
for Server Name Indication capabilities of a gRPC server?
I would like to use SNI to switch the server certificates used based on the host name.
Issue Analytics
- State:
- Created 3 years ago
- Comments:19 (7 by maintainers)
Top Results From Across the Web
NettyServerBuilder (grpc-all 1.51.0 API)
Creates a server builder configured with the given SocketAddress . Parameters: address - the socket address on which the server is to be...
Read more >Example usage for io.netty.handler.ssl SniHandler SniHandler
In this page you can find the example usage for io.netty.handler.ssl SniHandler SniHandler. Prototype. @SuppressWarnings("unchecked") public SniHandler( ...
Read more >io.grpc.netty.NettyServerBuilder.fallbackHandlerRegistry java ...
How to use. fallbackHandlerRegistry ... Best Java code snippets using io.grpc.netty. ... Before the test has started, create the server and channel.
Read more >io.netty.handler.ssl.SniHandler Maven / Gradle / Ivy
The class is part of the package ➦ Group: io.netty ➦ Artifact: netty-handler ... Creates a SNI detection handler with configured {@link SslContext} ......
Read more >How to instantiate a grpc server using ssl in java using java ...
I would advice to use NettyServerBuilder which is capable of ... GrpcSslContexts.configure(sslContextBuilder).build(); Server server ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s already handled. Lots of modern Internet infrastructure would break without the client providing SNI.
I’d accept “it is a huge pain to configure multiple aliases,” but it is possible. The alias lookup is part of the KeyManager, so you can totally return them. Java’s
keytool
can be used to create a keystore with multiple aliases, either JKS or PKCS12.After poking around a bit, it looks like this actually works out-of-the-box (in the Java sense, not gRPC), where you don’t need to write any SNI lookup code, as long as you have multiple entries in your keystore. Java’s “New” X509KeyManager searches through all the aliases looking for a certificate that matches the SNI name. You just have to make sure to use the newer X509 key manager and not the older SunX509 key manager.
To make the keystore, I used openssl to create p12 files of the cert+key. Then I used keytool to combine them into a single file. (I used “changeit” as all my passwords)
And then to create the Netty SslContext:
It is possible to build the KeyStore at runtime, but converting a file-based private key to the Java PrivateKey class is needlessly annoying. Normally Netty’s utilities do that for you, but that’s not available here to my knowledge.
SNI is already handled. I think via passing “host” to
newEngine()
. In any case, lots of stuff would break if it was broken, and I did actually test that code snippet with an unmodified client and the client-provided hostname did change the certificate returned. I also saw the SNI name show up in Wireguard.So there should be no need to change anything on client-side.