SQL 服务器连接在登录过程中被强行关闭

SQL Server- connection forcibly closed during login process

场景如下:

从 Windows Server 2003 到 SQL Server 2005 的连接工作顺利。现在一个新的 Windows 2012 服务器托管相同的 .net web 应用程序无法连接到相同的 SQL 服务器数据库,它失败并出现以下错误:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider,error: 0 - An existing connection was forcibly closed by the remote host.)]

由于它从 Windows 2003 年开始运行良好,我猜问题可能是以下之一:

  1. 向后兼容性问题,因为新盒子是 Windows 2012 而不是 Windows 2003。

  2. 网络连接问题。但是我可以确认网络路径没有问题,因为我可以从 Web 服务器远程登录端口 1433 到数据库服务器,并且部分错误消息是

    A connection was successfully established with the server

如有任何帮助,我们将不胜感激。

您需要检查您的 SSL 和 TLS 设置(服务器只允许 1.2,您的客户端只支持 1.0。)

查看以下知识库页面了解更多信息

TLS 1.2 support for Microsoft SQL Server

您需要为 Windows Server 2003 安装此修补程序。它将 TLS_RSA_WITH_AES_128_CBC_SHA AES128-SHATLS_RSA_WITH_AES_256_CBC_SHA AES256-SHA 密码套件添加到 Windows Server 2003。

如果没有将这 2 个密码套件添加到 Windows Server 2003,来自 Windows Server 2008 R2 及更高版本的任何内容都将无法创建到 Windows Server 2003 的 SSL 连接。这包括 SQL 服务器连接,以及任何其他依赖 SSL 的连接。

为什么?因为 Windows Server 2008 R2 及更高版本没有与 Windows Server 2003 相匹配的密码(出于安全原因,旧密码已从新 OS 中全部删除);因此 Windows Server 2003 断开连接,因为没有可用的匹配密码。

Windows Server 2003 的 Microsoft 修补程序:https://support.microsoft.com/en-us/help/948963

我有一条非常相似的错误消息:

Microsoft ODBC Driver {Version number here} for SQL Server : SSL Provider: An existing connection was forcibly closed by the remote host.

我发现 this guide and this post to be very helpful on this issue. One suggestion was to "upgrade your ODBC driver”,试过了但没有用,其他大部分讨论都是围绕某种形式的“检查您的 SSL 设置”展开的。

我为解决问题所做的工作是在我的 SQL 服务器上启用 TLS 1.0、1.1 和 1.2(在我的情况下是 2019 年),然后在我的客户端系统上仅启用 TLS 1.0 和 1.1(明确禁用 TLS 1.2) 使用toolset linked here。这似乎解决了我的问题。