需要在设置协议类型前需要先设置协议版本信息,如下:

HttpWebRequestreq = (HttpWebRequest)HttpWebRequest.Create(url);

ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
//设置协议类型前设置协议版本
req.ProtocolVersion
= HttpVersion.Version11; //这里设置了协议类型。 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; ServicePointManager.CheckCertificateRevocationList = true; ServicePointManager.DefaultConnectionLimit = 1000; ServicePointManager.Expect100Continue = false;

 

public bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
    return true;
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2021-11-14
  • 2022-12-23
  • 2019-08-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
相关资源
相似解决方案