Skip to content

Commit 717053e

Browse files
authored
Init SslContext when channel inited (#15664)
1 parent 87d6786 commit 717053e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ protected void initBootstrap(NettyClientHandler nettyClientHandler) {
122122
.channel(socketChannelClass());
123123

124124
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.max(DEFAULT_CONNECT_TIMEOUT, getConnectTimeout()));
125-
SslContext sslContext = SslContexts.buildClientSslContext(getUrl());
126125
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
127126

128127
@Override
129128
protected void initChannel(SocketChannel ch) throws Exception {
130129
int heartbeatInterval = UrlUtils.getHeartbeat(getUrl());
131130

131+
SslContext sslContext = SslContexts.buildClientSslContext(getUrl());
132132
if (sslContext != null) {
133133
ch.pipeline().addLast("negotiation", new SslClientTlsHandler(sslContext));
134134
}

dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyConnectionClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ private void initBootstrap() {
113113

114114
final NettyConnectionHandler connectionHandler = new NettyConnectionHandler(this);
115115
nettyBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, getConnectTimeout());
116-
SslContext sslContext = SslContexts.buildClientSslContext(getUrl());
117116
nettyBootstrap.handler(new ChannelInitializer<SocketChannel>() {
118117
@Override
119118
protected void initChannel(SocketChannel ch) {
120119
NettyChannel nettyChannel = NettyChannel.getOrAddChannel(ch, getUrl(), getChannelHandler());
121120
final ChannelPipeline pipeline = ch.pipeline();
122121
NettySslContextOperator nettySslContextOperator = new NettySslContextOperator();
123122

123+
SslContext sslContext = SslContexts.buildClientSslContext(getUrl());
124124
if (sslContext != null) {
125125
pipeline.addLast("negotiation", new SslClientTlsHandler(sslContext));
126126
}

0 commit comments

Comments
 (0)