“因为算法不同,客户端与服务器无法通信。”的解决方法

 

先说明我的环境,站点和数据库是分开部署的。

站点服务器:windows server 2016、.net framework 4.6.1

数据库服务器:windows server 2016、sql server 2008 R2

 

根据网上的帖子,设置了如下代码也不起效果:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

// 或者

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

具体原因可以看这篇讨论帖:https://stackoverflow.com/questions/26742054/the-client-and-server-cannot-communicate-because-they-do-not-possess-a-common-a

 

最后根据微软文档的说明,改动注册表就成功了:https://docs.microsoft.com/zh-cn/windows-server/security/tls/tls-registry-settings

具体我的做法是:

1、把几个“SSL”的关闭掉,就是把它的“Enabled”设置为0。

2、把几个“TLS”的“DisabledByDefault”设置为0,“Enabled”设置为1,Client和Server都要这样设置。

3、两台服务器的设置一致,然后需要重启电脑才可生效。

 

posted @ 2022-04-06 17:44  水沽籽  阅读(3961)  评论(2编辑  收藏  举报