Only enable trust server certificate if encryption enabled.

This commit is contained in:
mike12345567 2023-06-29 15:23:08 +01:00 committed by Adria Navarro
parent 7b6246ee59
commit 63d16f1809
1 changed files with 5 additions and 2 deletions

View File

@ -184,15 +184,18 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
async connect() { async connect() {
try { try {
const encrypt = this.config.encrypt
const clientCfg: MSSQLConfig & sqlServer.config = { const clientCfg: MSSQLConfig & sqlServer.config = {
...this.config, ...this.config,
port: +this.config.port, port: +this.config.port,
options: { options: {
encrypt: this.config.encrypt, encrypt: encrypt,
enableArithAbort: true, enableArithAbort: true,
trustServerCertificate: true,
}, },
} }
if (encrypt) {
clientCfg.options!.trustServerCertificate = true
}
delete clientCfg.encrypt delete clientCfg.encrypt
if (this.config.authType === MSSQLConfigAuthType.ACTIVE_DIRECTORY) { if (this.config.authType === MSSQLConfigAuthType.ACTIVE_DIRECTORY) {