C# 将.net客户端升级到TSL1.2以与restful服务通信
我正在尝试从asp.net客户端访问restful服务。我正在发出web请求并设置代理和其他参数。web服务器将只接受最新修补版本的OpenSSL密码套件的安全集 代码如下:C# 将.net客户端升级到TSL1.2以与restful服务通信,c#,web-services,rest,security,ssl,C#,Web Services,Rest,Security,Ssl,我正在尝试从asp.net客户端访问restful服务。我正在发出web请求并设置代理和其他参数。web服务器将只接受最新修补版本的OpenSSL密码套件的安全集 代码如下: //string acadiaPath = "https://Test/AP/get?v=1&sk=0"; //string User = "****"; //string Pword = "******"; Serv
//string acadiaPath = "https://Test/AP/get?v=1&sk=0";
//string User = "****";
//string Pword = "******";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
System.Net.WebRequest request = System.Net.HttpWebRequest.Create(acadiaPath);
request.Method = "GET";
request.UseDefaultCredentials = true;
request.ContentLength = 0;
Uri newUri = new Uri(proxyAddress);
myProxy.Address = newUri;
myProxy.Credentials = CredentialCache.DefaultCredentials;
request.Proxy = myProxy;
request.Credentials = new NetworkCredential(acadiaUser, acadiaPword);
System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse;
Stream objResponseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(objResponseStream);
string objResponseString = reader.ReadToEnd();
MessageBox.Show(objResponseStream.ToString());
但这并没有通过,下面是错误:
基础连接已关闭:发送时发生意外错误
原因是:
ServicePointManager.SecurityProtocol=SecurityProtocolType.Tls
这不提供TSL1.2,因为我的客户机代码在4.0上
如何在不从c代码升级到4.5的情况下使用TSL1.2。我的意思是使用4.5提供的system.net DLL或任何其他东西
有什么建议吗?有什么原因不能切换到4.5吗?有。当前的设置是在XP上,我们不想增加额外的成本。在4.0上使用它有什么解决方法吗?