25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(sqlserver): initialize legacy TLS compatibility earlier
zipgcc72b7a4e7c5
diff --git a/agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.java b/agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.javaindex 6a390e094e..eac8b40359 100644--- a/agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.java+++ b/agents/drivers/sqlserver-legacy/src/main/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgent.java@@ -6,6 +6,10 @@ import com.dbx.agent.JdbcAgentProfile;import com.dbx.agent.JsonRpcServer;import java.security.Security;+import java.sql.Connection;+import java.sql.Driver;+import java.sql.DriverManager;+import java.sql.SQLException;import java.util.ArrayList;import java.util.Arrays;import java.util.LinkedHashMap;@@ -45,14 +49,25 @@ public final class SqlServerLegacyAgent extends ConfiguredJdbcAgent {public SqlServerLegacyAgent() {super(PROFILE);+ // AbstractJdbcAgent loads the JDBC driver before building the URL, so relax+ // the legacy TLS policy here before the driver can initialize JSSE.+ enableLegacyTlsAlgorithms();}@Overrideprotected String buildJdbcUrl(ConnectParams params) {- enableLegacyTlsAlgorithms();return legacyTlsUrl(params);}+ @Override+ protected Connection openConnection(ConnectParams params) throws Exception {+ try {+ return super.openConnection(params);+ } catch (SQLException error) {+ throw withLegacyTlsDiagnostics(error);+ }+ }+static String legacyTlsUrl(ConnectParams params) {Map<String, String> properties = baseConnectionProperties(params);properties.put("encrypt", "true");@@ -79,6 +94,53 @@ public final class SqlServerLegacyAgent extends ConfiguredJdbcAgent {return String.join(", ", kept);}+ static String legacyTlsDiagnostics() {+ String disabledAlgorithms = Security.getProperty(TLS_DISABLED_ALGORITHMS_KEY);+ return "DBX SQL Server legacy TLS diagnostics: java=" + System.getProperty("java.version", "unknown")+ + ", javaVendor=" + System.getProperty("java.vendor", "unknown")+ + ", jdbc=" + jdbcDriverVersion()+ + ", sslProtocol=TLSv1"+ + ", tlsV1Disabled=" + isDisabled(disabledAlgorithms, "TLSV1")+ + ", 3desDisabled=" + isDisabled(disabledAlgorithms, "3DES_EDE_CBC")+ + ", rc4Disabled=" + isDisabled(disabledAlgorithms, "RC4");+ }++ static SQLException withLegacyTlsDiagnostics(SQLException error) {+ String message = error.getMessage() == null ? error.toString() : error.getMessage();+ return new SQLException(+ message + "\n\n" + legacyTlsDiagnostics(),+ error.getSQLState(),+ error.getErrorCode(),+ error+ );+ }++ private static boolean isDisabled(String disabledAlgorithms, String algorithm) {+ if (disabledAlgorithms == null || disabledAlgorithms.trim().isEmpty()) {+ return false;+ }+ for (String rawPart : disabledAlgorithms.split(",")) {+ if (algorithm.equals(rawPart.trim().toUpperCase(Locale.ROOT))) {+ return true;+ }+ }+ return false;+ }++ private static String jdbcDriverVersion() {+ try {+ Driver driver = DriverManager.getDriver("jdbc:sqlserver://localhost");+ Package driverPackage = driver.getClass().getPackage();+ String implementationVersion = driverPackage == null ? null : driverPackage.getImplementationVersion();+ if (implementationVersion != null && !implementationVersion.trim().isEmpty()) {+ return implementationVersion;+ }+ return driver.getMajorVersion() + "." + driver.getMinorVersion();+ } catch (SQLException ignored) {+ return "unknown";+ }+ }+private static void enableLegacyTlsAlgorithms() {String current = Security.getProperty(TLS_DISABLED_ALGORITHMS_KEY);String relaxed = relaxedDisabledAlgorithms(current);diff --git a/agents/drivers/sqlserver-legacy/src/test/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgentTest.java b/agents/drivers/sqlserver-legacy/src/test/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgentTest.javaindex 50eb1bd2e9..2f3249fb45 100644--- a/agents/drivers/sqlserver-legacy/src/test/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgentTest.java+++ b/agents/drivers/sqlserver-legacy/src/test/java/com/dbx/agent/sqlserverlegacy/SqlServerLegacyAgentTest.java@@ -4,7 +4,43 @@ import com.dbx.agent.ConnectParams;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;+import java.security.Security;+import java.sql.SQLException;+class SqlServerLegacyAgentTest {+ @Test+ void constructorRelaxesLegacyTlsPolicyBeforeDriverLoading() {+ String key = "jdk.tls.disabledAlgorithms";+ String original = Security.getProperty(key);+ try {+ Security.setProperty(key, "TLSv1, TLSv1.1, 3DES_EDE_CBC, EC keySize < 224");++ new SqlServerLegacyAgent();++ Assertions.assertEquals("EC keySize < 224", Security.getProperty(key));+ String diagnostics = SqlServerLegacyAgent.legacyTlsDiagnostics();+ Assertions.assertTrue(diagnostics.contains("sslProtocol=TLSv1"));+ Assertions.assertTrue(diagnostics.contains("tlsV1Disabled=false"));+ Assertions.assertTrue(diagnostics.contains("3desDisabled=false"));+ Assertions.assertTrue(diagnostics.contains("rc4Disabled=false"));+ } finally {+ Security.setProperty(key, original == null ? "" : original);+ }+ }++ @Test+ void connectionErrorsPreserveDetailsAndIncludeRuntimeDiagnostics() {+ SQLException original = new SQLException("TLS handshake failed", "08001", 1234);++ SQLException error = SqlServerLegacyAgent.withLegacyTlsDiagnostics(original);++ Assertions.assertEquals("08001", error.getSQLState());+ Assertions.assertEquals(1234, error.getErrorCode());+ Assertions.assertSame(original, error.getCause());+ Assertions.assertTrue(error.getMessage().contains("TLS handshake failed"));+ Assertions.assertTrue(error.getMessage().contains("DBX SQL Server legacy TLS diagnostics:"));+ }+@Testvoid legacyTlsUrlUsesSqlServerTlsV1Properties() {ConnectParams params = new ConnectParams(