This is an automated email from the ASF dual-hosted git repository.
crazyhzm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new ae6c6a9 Fix netty server ssl context file leak (#9246)
ae6c6a9 is described below
commit ae6c6a9a9ab1aa0b3d911243097a12ed4d00009d
Author: haoyann <[email protected]>
AuthorDate: Wed Nov 10 13:40:37 2021 +0800
Fix netty server ssl context file leak (#9246)
---
.../org/apache/dubbo/remoting/transport/netty4/SslContexts.java | 7 +++++--
.../java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java | 4 +++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/SslContexts.java
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/SslContexts.java
index b74e15b..6eeb777 100644
---
a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/SslContexts.java
+++
b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/SslContexts.java
@@ -46,9 +46,11 @@ public class SslContexts {
SslContextBuilder sslClientContextBuilder = null;
InputStream serverKeyCertChainPathStream = null;
InputStream serverPrivateKeyPathStream = null;
+ InputStream serverTrustCertStream = null;
try {
serverKeyCertChainPathStream =
sslConfig.getServerKeyCertChainPathStream();
serverPrivateKeyPathStream =
sslConfig.getServerPrivateKeyPathStream();
+ serverTrustCertStream =
sslConfig.getServerTrustCertCollectionPathStream();
String password = sslConfig.getServerKeyPassword();
if (password != null) {
sslClientContextBuilder =
SslContextBuilder.forServer(serverKeyCertChainPathStream,
@@ -58,8 +60,8 @@ public class SslContexts {
serverPrivateKeyPathStream);
}
- if (sslConfig.getServerTrustCertCollectionPathStream() != null) {
-
sslClientContextBuilder.trustManager(sslConfig.getServerTrustCertCollectionPathStream());
+ if (serverTrustCertStream != null) {
+ sslClientContextBuilder.trustManager(serverTrustCertStream);
sslClientContextBuilder.clientAuth(ClientAuth.REQUIRE);
}
if (sslConfig.getCiphers() != null) {
@@ -74,6 +76,7 @@ public class SslContexts {
}finally {
safeCloseStream(serverKeyCertChainPathStream);
safeCloseStream(serverPrivateKeyPathStream);
+ safeCloseStream(serverTrustCertStream);
}
try {
return
sslClientContextBuilder.sslProvider(findSslProvider()).build();
diff --git
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
index 8035ae1..855454d 100644
---
a/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
+++
b/dubbo-rpc/dubbo-rpc-grpc/src/main/java/org/apache/dubbo/rpc/protocol/grpc/GrpcOptionsUtils.java
@@ -164,6 +164,7 @@ public class GrpcOptionsUtils {
SslContextBuilder sslClientContextBuilder = null;
InputStream serverKeyCertChainPathStream = null;
InputStream serverPrivateKeyPathStream = null;
+ InputStream trustCertCollectionFilePath = null;
try {
serverKeyCertChainPathStream =
sslConfig.getServerKeyCertChainPathStream();
serverPrivateKeyPathStream =
sslConfig.getServerPrivateKeyPathStream();
@@ -176,7 +177,7 @@ public class GrpcOptionsUtils {
serverPrivateKeyPathStream);
}
- InputStream trustCertCollectionFilePath =
sslConfig.getServerTrustCertCollectionPathStream();
+ trustCertCollectionFilePath =
sslConfig.getServerTrustCertCollectionPathStream();
if (trustCertCollectionFilePath != null) {
sslClientContextBuilder.trustManager(trustCertCollectionFilePath);
sslClientContextBuilder.clientAuth(ClientAuth.REQUIRE);
@@ -186,6 +187,7 @@ public class GrpcOptionsUtils {
}finally {
safeCloseStream(serverKeyCertChainPathStream);
safeCloseStream(serverPrivateKeyPathStream);
+ safeCloseStream(trustCertCollectionFilePath);
}
try {
return sslClientContextBuilder.build();