diff --git a/packages/web/src/settings/ConnectionDriverFields.svelte b/packages/web/src/settings/ConnectionDriverFields.svelte
index 6d01b00a..cc5b04d7 100644
--- a/packages/web/src/settings/ConnectionDriverFields.svelte
+++ b/packages/web/src/settings/ConnectionDriverFields.svelte
@@ -168,6 +168,10 @@
{/if}
+{#if driver?.showConnectionField('trustServerCertificate', $values)}
+
+{/if}
+
{#if driver?.showConnectionField('defaultDatabase', $values)}
{/if}
diff --git a/plugins/dbgate-plugin-mssql/src/backend/tediousDriver.js b/plugins/dbgate-plugin-mssql/src/backend/tediousDriver.js
index e65bbe5d..67f6a4ed 100644
--- a/plugins/dbgate-plugin-mssql/src/backend/tediousDriver.js
+++ b/plugins/dbgate-plugin-mssql/src/backend/tediousDriver.js
@@ -22,7 +22,7 @@ function extractTediousColumns(columns, addDriverNativeColumn = false) {
return res;
}
-async function tediousConnect({ server, port, user, password, database, ssl }) {
+async function tediousConnect({ server, port, user, password, database, ssl, trustServerCertificate }) {
return new Promise((resolve, reject) => {
const connectionOptions = {
encrypt: !!ssl,
@@ -32,6 +32,7 @@ async function tediousConnect({ server, port, user, password, database, ssl }) {
validateBulkLoadParameters: false,
requestTimeout: 1000 * 3600,
port: port ? parseInt(port) : undefined,
+ trustServerCertificate: !!trustServerCertificate,
};
if (database) {
diff --git a/plugins/dbgate-plugin-mssql/src/frontend/driver.js b/plugins/dbgate-plugin-mssql/src/frontend/driver.js
index feca80c9..f696916c 100644
--- a/plugins/dbgate-plugin-mssql/src/frontend/driver.js
+++ b/plugins/dbgate-plugin-mssql/src/frontend/driver.js
@@ -126,7 +126,8 @@ const driver = {
showConnectionField: (field, values) =>
['authType', 'server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase', 'isReadOnly'].includes(
field
- ),
+ ) ||
+ (field == 'trustServerCertificate' && values.authType != 'sql' && values.authType != 'sspi'),
getQuerySplitterOptions: () => mssqlSplitterOptions,
engine: 'mssql@dbgate-plugin-mssql',