1、问题:
Win10/Win11更新系统补丁后,客户端程序不能连接SQLServer2015数据库,提示异常消息:
已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: SSL Provider, error: 0 - 证书链是由不受信任的颁发机构颁发的。)
2、处理
分析可能是新的补丁已经默认弃用或禁用旧版本TLS导致。在客户端电脑的PowerShell中执行如下命令后,再次运行程序连接正常。
foreach ($CipherSuite in $(Get-TlsCipherSuite).Name)
{
"Disabling cipher suite: " + $CipherSuite
Disable-TlsCipherSuite -Name $CipherSuite
}
Enable-TlsCipherSuite -Name TLS_AES_256_GCM_SHA384
Enable-TlsCipherSuite -Name TLS_AES_128_GCM_SHA256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
Enable-TlsCipherSuite -Name TLS_RSA_WITH_AES_256_GCM_SHA384
Enable-TlsCipherSuite -Name TLS_RSA_WITH_AES_128_GCM_SHA256
Enable-TlsCipherSuite -Name TLS_RSA_WITH_NULL_SHA256
Enable-TlsCipherSuite -Name TLS_RSA_WITH_NULL_SHA
Enable-TlsCipherSuite -Name TLS_PSK_WITH_AES_256_GCM_SHA384
Enable-TlsCipherSuite -Name TLS_PSK_WITH_AES_128_GCM_SHA256
Enable-TlsCipherSuite -Name TLS_PSK_WITH_AES_256_CBC_SHA384
Enable-TlsCipherSuite -Name TLS_PSK_WITH_AES_128_CBC_SHA256
Enable-TlsCipherSuite -Name TLS_PSK_WITH_NULL_SHA384
Enable-TlsCipherSuite -Name TLS_PSK_WITH_NULL_SHA256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384_P384
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P384
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA_P384
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA_P384
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA_P256
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA_P384
Enable-TlsCipherSuite -Name TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384_P384
Enable-TlsCipherSuite -Name TLS_RSA_WITH_AES_128_CBC_SHA256
Enable-TlsCipherSuite -Name TLS_RSA_WITH_AES_128_CBC_SHA
Enable-TlsCipherSuite -Name TLS_RSA_WITH_AES_256_CBC_SHA256
Enable-TlsCipherSuite -Name TLS_RSA_WITH_AES_256_CBC_SHA
Enable-TlsCipherSuite -Name TLS_RSA_WITH_3DES_EDE_CBC_SHA
3、参考
应用程序尝试连接到 Windows 中的SQL Server时出错 - Windows Server
windows 11 已成功与服务器建立连接,但是在登录过程中发生错误。 (provider: ssl 提供程序, error: 0 - 远程主机强迫关闭了一个现有的连接。)