The requested security protocol is not supported
.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;
The SSL connection could not be established, see inner exception
dotnet core在Linux(如:centOS)环境下使用HttpClient请求https可能会报异常:
One or more errors occurred. (The SSL connection could not be established, see inner exception.)
设置如下环境变量暂时解决:
export DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER=0
使用本地https证书
参考文章
.NetCore项目使用Https证书
.net core 配置安全证书及访问Https接口
asp.net core 2使用本地https证书
