diff --git a/Common/src/main/java/com/r3944realms/dg_lab/websocket/AbstractWebSocketServer.java b/Common/src/main/java/com/r3944realms/dg_lab/websocket/AbstractWebSocketServer.java index 21c2c25..be7f004 100644 --- a/Common/src/main/java/com/r3944realms/dg_lab/websocket/AbstractWebSocketServer.java +++ b/Common/src/main/java/com/r3944realms/dg_lab/websocket/AbstractWebSocketServer.java @@ -34,9 +34,11 @@ import io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; import java.io.File; import java.util.concurrent.CompletableFuture; @@ -56,7 +58,10 @@ public abstract class AbstractWebSocketServer { * Should enable SSL */ boolean SslEnabled; - + /** + * SSL 密码 + */ + String SslPassword; /** * Cert File */ @@ -166,9 +171,19 @@ public abstract class AbstractWebSocketServer { * @param keyFile 私钥文件 */ public void enableSSL(@NotNull File certFile, @NotNull File keyFile) { + enableSSL(certFile, keyFile, null); + } + /** + * 启用SSL + * @param certFile 证书文件 + * @param keyFile 私钥文件 + * @param password ssl密码 + */ + public void enableSSL(@NotNull File certFile, @NotNull File keyFile, @Nullable String password) { this.SslEnabled = true; this.CertFile = certFile; this.KeyFile = keyFile; + this.SslPassword = password; } /** @@ -210,7 +225,7 @@ public abstract class AbstractWebSocketServer { ChannelPipeline pipeline = ch.pipeline(); // 根据配置启用 SSL if (SslEnabled) { - SslContext sslCtx = SslContextBuilder.forServer(CertFile, KeyFile).build(); + SslContext sslCtx = SslContextBuilder.forServer(CertFile, KeyFile, SslPassword).build(); pipeline.addFirst(sslCtx.newHandler(ch.alloc())); } pipeline.addLast(DgLab.LOGGING_HANDLER); diff --git a/gradle.properties b/gradle.properties index dcb994d..9a5ad8e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ org.gradle.configuration-cache=true org.gradle.configuration-cache.problems=warn # ROOT project_name=DgLab -project_version=4.2.10.18 +project_version=4.2.11.18 project_group=top.r3944realms.dg_lab # API diff --git a/versionlog.txt b/versionlog.txt index 81770c3..6e889b8 100644 --- a/versionlog.txt +++ b/versionlog.txt @@ -2,12 +2,15 @@ 统一用4位版本,对于测试性更新统一在其后加-Beta。 修复问题更新为加0.0.0.1,添加/移除新特性加0.0.1.0,小部分重构更新加0.1.0.0,大量重构加1.0.0.0 +2025-09-21-4 +project_version=4.2.11.18 +* 添加服务器对SSL密码参数支持 + 2025-09-21-3 project_version=4.2.10.18 * 添加ClientPowerBoxSharedData添加新字段 isEnableSsl,用于WS地址协议头判断 * 让PowerBoxWSClient继承了父类的#enableSSL #disableSSL方法以适配添加ClientPowerBoxSharedData添加新字段的字段 isEnableSsl - 2025-09-21-2 project_version=4.2.10.17 * 修正 DGPBClientManager 的实现接口为com.r3944realms.dg_lab.api.manager.IDGLabManager