异常如下
方法 - 增加cryptoCredentialsDetails.minVersion配置
关键
cryptoCredentialsDetails: {
minVersion: 'TLSv1'
}
sequelize
const sequelize = new Sequelize(database, user, password, {
host,
dialect: 'mssql',
dialectOptions: {
options: {
cryptoCredentialsDetails: {
minVersion: 'TLSv1'
}
}
}
});
await sequelize.authenticate();
mssql
mssql.connect({
user,
password,
server,
database,
options: {
cryptoCredentialsDetails: {
minVersion: 'TLSv1'
}
}
});
原因
Node12开始,默认情况下需要 TLS 1.2。如果 SQL Server 服务器不支持 TLS 1.2,则会抛出 “SSL routines:ssl_choose_client_version:unsupported protocol” 错误。