C# 请求被中止:无法使用Restsharp创建SSL/TLS安全通道
我正在尝试连接服务文件(.svc)。从我的c#代码中,但我得到的信息是 请求被中止:无法创建SSL/TLS安全通道 服务器只接受下面的密码 接受的密码如下所示: TLSv1.2 128位ECDHE-RSA-AES128-GCM-SHA256曲线p-256 DHE 256 TLSv1.2 256位ECDHE-RSA-AES256-GCM-SHA384曲线p-256 DHE 256 代码: 尝试了以下解决方案 1) 在TLS1.2启用的行下方添加C# 请求被中止:无法使用Restsharp创建SSL/TLS安全通道,c#,security,asp.net-mvc-4,ssl,restsharp,C#,Security,Asp.net Mvc 4,Ssl,Restsharp,我正在尝试连接服务文件(.svc)。从我的c#代码中,但我得到的信息是 请求被中止:无法创建SSL/TLS安全通道 服务器只接受下面的密码 接受的密码如下所示: TLSv1.2 128位ECDHE-RSA-AES128-GCM-SHA256曲线p-256 DHE 256 TLSv1.2 256位ECDHE-RSA-AES256-GCM-SHA384曲线p-256 DHE 256 代码: 尝试了以下解决方案 1) 在TLS1.2启用的行下方添加 ServicePointManager.Securi
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
谢谢和问候
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });
var client = new RestClient(url);
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/xml");
request.AddParameter("undefined", str, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });