Add TLS SNI Extension in HTTP/2 Client request. (#9937)

Motivation:

Since "Http2ClientInitializer" creates a new SSLContext Handler without specifying Host, Netty does not add SNI Extension in TLS Client Hello request and the request fails if the server uses SNI to establish TLS Connection. 

Modification:

Specified Host while creating a new SSLContext Handler in "Http2ClientInitializer".

Result:

Netty adds SNI Extension of the Host Specified in new SSLContext Handler and sends it with TLS Client Hello request.

Fixes #9815.
This commit is contained in:
Aayush Atharva 2020-01-10 21:04:06 +05:30 committed by Norman Maurer
parent ac69c877f1
commit f7d357312f

View File

@ -98,7 +98,8 @@ public class Http2ClientInitializer extends ChannelInitializer<SocketChannel> {
*/
private void configureSsl(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast(sslCtx.newHandler(ch.alloc()));
// Specify Host in SSLContext New Handler to add TLS SNI Extension
pipeline.addLast(sslCtx.newHandler(ch.alloc(), Http2Client.HOST, Http2Client.PORT));
// We must wait for the handshake to finish and the protocol to be negotiated before configuring
// the HTTP/2 components of the pipeline.
pipeline.addLast(new ApplicationProtocolNegotiationHandler("") {