.Net Core访问https接口报错:The requested security protocol is not supported


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

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;
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM