jjzjj

SecurityProtocol

全部标签

c# - 为什么 ServicePointManager.SecurityProtocol 默认值在不同机器上不同?

目前我有一个问题,找不到严格的答案。我有针对4.6.1框架的ASP.NETMVC5应用程序,它的目标是使用受TLS1.1/TLS1.2协议(protocol)保护的第三方API。我尝试在2个环境中运行我的应用程序:我的本地计算机Windows10,带有.NET4.6.2Framework,IISExpress;服务器计算机WindowsServer2012,带.NET4.6.1、IIS8.0;问题在于,当我在本地启动它时ServicePointManager.SecurityProtocol默认值设置为Ssl3,Tls,所以我无法定位API,必须编写代码它在应用程序上开始使用TLS1.

c# - 在没有显式 ServicePointManager.SecurityProtocol 调用的情况下,.NET 4.7 中未协商 TLS 1.2

我需要升级.NET应用程序以支持在仅支持TLS1.2的网站上调用API。据我了解,如果应用程序的目标是4.6或更高版本,那么它将默认使用TLS1.2。为了测试,我创建了一个面向4.7的Windows窗体应用程序。不幸的是,当我没有明确设置ServicePointManager.SecurityProtocol时它会出错。这是代码:HttpClient_client=newHttpClient();varmsg=newStringBuilder();//IfIuncommentthenextlineitworks,butfailsevenwith4.7//ServicePointMana