简体   繁体   中英

How to encrypt connection to SQL Server in Node.js

I am using the mssql client for node.js to connect to SQL Server 2014. This is working great, however there is now a new requirement to use the highest level encryption (TLS 1.2) for communications to all databases. The only documentation I am able to find on encrypted connection to SQL Server in Node.js is the encrypt:true property of the connection options which is designated for Azure connections. This is an on-premise database, when i do set encrypt:true the connection just stalls. No error, just does not successfully connect. Any help with direction on this is greatly appreciated.

After doing some testing with MSSQL driver, I was able to successfully connect to SQL Server 2014 over TLS 1.2 by having our DBA's force encryption at the database and require TLS 1.2, then adding the encrypt:true property to the connection options. Our production app has an ORM layer through Sequelize so using the native MSSQL under the hood, I added

dialectOptions {
    encrypt: true
}

to the Sequelize connection object and tada

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM