The reason why the error is thrown has to do with a change in Node.js 12. Since version 12, the TLS settings were tightened, and TLS 1.2 is required by default. The SSL routines:ssl_choose_client_version:unsupported protocol error would be thrown if the SQL Server server does not support TLS 1.2.
In Node, it is possible to change the default setting by using the command line flag --tls-min-v1.0
when starting node. Since NW does not have a way to pass a command line flag to the Node context, the solution is to set a custom cryptoCredentialsDetails
option in the connection configuration that specifies minVersion: 'TLSv1'
, like the following:
mssql.connect({
user: "this.user",
password: "this.password",
server: "this.server",
database: "this.database",
options: {
cryptoCredentialsDetails: {
minVersion: 'TLSv1'
}
}
});