Hi, anyone,
as title mentioned, the worked code with node 10, not work with node 12, it report:
Connection lost - 3540:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol:c:\ws\deps\openssl\openssl\ssl\statem\statem_lib.c:1922:
{"message":"Failed to connect to localhost:1433 - Cannot call write after a stream was destroyed","code":"ESOCKET"}
any help ? the OS is windows 10 64bit, SQL Server is 2012 64bit
problem solved!
with node 12+, config changed as:
const config: ConnectionConfig = {
server: '...',
authentication: { type: 'default', options: { userName: '...', password: '...' } },
options: { ...,encrypt:false }
}
Hey @c5soft! 👋
I understand that disabling encryption "solved" your problem here. This might be acceptable for your use case, but disabling encryption is not really a solution. 😅
For those that run into a similar error, this is because since Node.js 12, the default TLS settings were tightened. Most likely your SQL Server does not support TLS 1.2, but it's required by default in Node.js 12. You can change this either via a command line flag when starting node (e.g. --tls-min-v1.0
), or by passing a custom cryptoCredentialsDetails
option to the Connection
constructor that specifies minVersion: 'TLSv1'
or whatever TLS version you need to use.
Just in case someone runs into this, the same thing happened with activeDirectory2 for node, based on LDAPJS: adding that option to tlsOptions solved the problem
problem solved!
with node 12+, config changed as:
const config: ConnectionConfig = {
server: '...',
authentication: { type: 'default', options: { userName: '...', password: '...' } },
options: { ...,encrypt:false }
}
Thanks !!!
Hey @c5soft! 👋
I understand that disabling encryption "solved" your problem here. This might be acceptable for your use case, but disabling encryption is not really a solution. 😅
For those that run into a similar error, this is because since Node.js 12, the default TLS settings were tightened. Most likely your SQL Server does not support TLS 1.2, but it's required by default in Node.js 12. You can change this either via a command line flag when starting node (e.g.
--tls-min-v1.0
), or by passing a customcryptoCredentialsDetails
option to theConnection
constructor that specifiesminVersion: 'TLSv1'
or whatever TLS version you need to use.
thank you so much!
it works in my nestjs project!
for those who has the same problem in nestjs.
TypeOrmModule.forRoot({
type: 'mssql',
host: 'localhost',
port: 1433,
username: 'root',
password: 'root',
database: 'test',
entities: [],
synchronize: true,
options: {
cryptoCredentialsDetails: {
minVersion: 'TLSv1'
}
}
}),
Most helpful comment
problem solved!
with node 12+, config changed as:
const config: ConnectionConfig = {
server: '...',
authentication: { type: 'default', options: { userName: '...', password: '...' } },
options: { ...,encrypt:false }
}