每个httpclient /请求的安全协议(HttpClient)

时间:2018-12-21 06:24:02

标签: c# tls1.2 dotnet-httpclient

我遇到的问题与this question中的问题相同。

var handler = new WebRequestHandler();
handler.ClientCertificates.Add(cacert2);
var client = new HttpClient(handler, true);
var result = await client.PostAsync(uri, content); //tls 1.0

对服务的此请求仅适用于默认的安全协议(TLS)。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; //default .net 4.5

如果我使用

ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

,该服务显示错误400 No required SSL certificate was sent

如何为每个httpclient设置协议?

0 个答案:

没有答案