From 63d16f1809b109db81aaed3f5f051e7b2d25249a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 29 Jun 2023 15:23:08 +0100 Subject: [PATCH] Only enable trust server certificate if encryption enabled. --- packages/server/src/integrations/microsoftSqlServer.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/microsoftSqlServer.ts b/packages/server/src/integrations/microsoftSqlServer.ts index 9c4f5d074d..2c1f069e8a 100644 --- a/packages/server/src/integrations/microsoftSqlServer.ts +++ b/packages/server/src/integrations/microsoftSqlServer.ts @@ -184,15 +184,18 @@ class SqlServerIntegration extends Sql implements DatasourcePlus { async connect() { try { + const encrypt = this.config.encrypt const clientCfg: MSSQLConfig & sqlServer.config = { ...this.config, port: +this.config.port, options: { - encrypt: this.config.encrypt, + encrypt: encrypt, enableArithAbort: true, - trustServerCertificate: true, }, } + if (encrypt) { + clientCfg.options!.trustServerCertificate = true + } delete clientCfg.encrypt if (this.config.authType === MSSQLConfigAuthType.ACTIVE_DIRECTORY) {