首页 > 解决方案 > 如何验证nodejs应用程序中的mssql连接是否加密?

问题描述

我们知道,通过给出以下配置,我们可以使用“mssql”包在 nodejs 应用程序中创建加密连接。

const configDB = {
      server: ServerName,
      user: USER_ID,
      password: pwd,
      database: DatabaseName,
      port: SQL_PORT,
      pool: {
        min: 1,
        max: 10
      },
      options: {
        encrypt: true
      }
    };

给出的 encrypt:true 选项向我们保证连接将被加密。但是有没有办法验证连接是否加密?

标签: javascriptnode.jssql-server

解决方案


运行此查询以检查当前连接是否已加密

select encrypt_option
from sys.dm_exec_connections
where session_id = @@spid

推荐阅读