Skip to content

Commit 5c4dd0d

Browse files
committed
feat(添加支持): 添加服务器对SSL密码参数支持
1 parent c8ae336 commit 5c4dd0d

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

Common/src/main/java/com/r3944realms/dg_lab/websocket/AbstractWebSocketServer.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@
3434
import io.netty.handler.ssl.SslContext;
3535
import io.netty.handler.ssl.SslContextBuilder;
3636
import org.jetbrains.annotations.NotNull;
37+
import org.jetbrains.annotations.Nullable;
3738
import org.slf4j.Logger;
3839
import org.slf4j.LoggerFactory;
3940

41+
import javax.net.ssl.SSLContext;
4042
import javax.net.ssl.SSLException;
4143
import java.io.File;
4244
import java.util.concurrent.CompletableFuture;
@@ -56,7 +58,10 @@ public abstract class AbstractWebSocketServer {
5658
* Should enable SSL
5759
*/
5860
boolean SslEnabled;
59-
61+
/**
62+
* SSL 密码
63+
*/
64+
String SslPassword;
6065
/**
6166
* Cert File
6267
*/
@@ -166,9 +171,19 @@ public boolean isSSLEnabled() {
166171
* @param keyFile 私钥文件
167172
*/
168173
public void enableSSL(@NotNull File certFile, @NotNull File keyFile) {
174+
enableSSL(certFile, keyFile, null);
175+
}
176+
/**
177+
* 启用SSL
178+
* @param certFile 证书文件
179+
* @param keyFile 私钥文件
180+
* @param password ssl密码
181+
*/
182+
public void enableSSL(@NotNull File certFile, @NotNull File keyFile, @Nullable String password) {
169183
this.SslEnabled = true;
170184
this.CertFile = certFile;
171185
this.KeyFile = keyFile;
186+
this.SslPassword = password;
172187
}
173188

174189
/**
@@ -210,7 +225,7 @@ protected void initChannel(NioSocketChannel ch) throws SSLException {
210225
ChannelPipeline pipeline = ch.pipeline();
211226
// 根据配置启用 SSL
212227
if (SslEnabled) {
213-
SslContext sslCtx = SslContextBuilder.forServer(CertFile, KeyFile).build();
228+
SslContext sslCtx = SslContextBuilder.forServer(CertFile, KeyFile, SslPassword).build();
214229
pipeline.addFirst(sslCtx.newHandler(ch.alloc()));
215230
}
216231
pipeline.addLast(DgLab.LOGGING_HANDLER);

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=true
77
org.gradle.configuration-cache.problems=warn
88
# ROOT
99
project_name=DgLab
10-
project_version=4.2.10.18
10+
project_version=4.2.11.18
1111
project_group=top.r3944realms.dg_lab
1212

1313
# API

versionlog.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
统一用4位版本,对于测试性更新统一在其后加-Beta。
33
修复问题更新为加0.0.0.1,添加/移除新特性加0.0.1.0,小部分重构更新加0.1.0.0,大量重构加1.0.0.0
44

5+
2025-09-21-4
6+
project_version=4.2.11.18
7+
* 添加服务器对SSL密码参数支持
8+
59
2025-09-21-3
610
project_version=4.2.10.18
711
* 添加ClientPowerBoxSharedData添加新字段 isEnableSsl,用于WS地址协议头判断
812
* 让PowerBoxWSClient继承了父类的#enableSSL #disableSSL方法以适配添加ClientPowerBoxSharedData添加新字段的字段 isEnableSsl
913

10-
1114
2025-09-21-2
1215
project_version=4.2.10.17
1316
* 修正 DGPBClientManager 的实现接口为com.r3944realms.dg_lab.api.manager.IDGLabManager

0 commit comments

Comments
 (0)