fix: 修复SQL Server TLS协议兼容性问题

This commit is contained in:
Your Name 2026-01-06 18:58:03 +08:00
parent e0176fb174
commit 5837a240cd

View File

@ -24,6 +24,21 @@ import java.util.Map;
public class ThirdPartyDbService {
private final ThirdPartyDbConfigMapper configMapper;
// 静态初始化块:移除 TLS 协议限制,以支持旧版 SQL Server
static {
try {
// 移除 TLS 1.0 和 TLS 1.1 的禁用限制
java.security.Security.setProperty("jdk.tls.disabledAlgorithms",
"SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL");
// 设置允许的 TLS 协议
System.setProperty("jdk.tls.client.protocols", "TLSv1,TLSv1.1,TLSv1.2");
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
log.info("已移除 TLS 协议限制,支持 TLSv1/TLSv1.1/TLSv1.2");
} catch (Exception e) {
log.warn("移除 TLS 限制失败: {}", e.getMessage());
}
}
/**
* 获取所有配置