C# 指定http请求使用Tls1.2

 

客户端语言
版本
类库
是否支持
兼容方案
 
Java 1.6.115之前   第三方支持包  
  1.6.115之后   启动jvm 添加参数-Dhttps.protocols=TLSv1.1,TLSv1.2   
  1.7   启动jvm 添加参数-Dhttps.protocols=TLSv1.1,TLSv1.2   
  1.8   默认支持  
Nodejs 各个版本   默认支持  
c#,asp.net 4.0-4.4  

在发送HTTP请求前加入下行代码

ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
 
  4.5  

如果是4.5以上版本可以直接使用

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;
 
Python  2.7-3   默认支持  
curl 7.19.7   默认支持  
Golang  1.7.4 net/http 默认支持  
Ruby          
php php5.6 file_get_contents    
    http\client    
    curl    
  php5.3.29 file_get_contents    
    http\client    
    curl    

 

posted @   代码沉思者  阅读(3231)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示