c# .net 4.0 HttpWebRequest 访问https TLS1.2 解决方案
来源:互联网 发布:逆矩阵怎么求 编辑:程序博客网 时间:2024/05/16 07:07
如标题所诉,和普通http访问没多大差别,只需要加一句
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
下面是完整的一个列子
public static string DoRequest(string Url, string cookieStr) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Timeout = 1000 *900; request.Headers.Add(HttpRequestHeader.Cookie, cookieStr); request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"; ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;// SecurityProtocolType.Tls1.2; string back =""; try { WebResponse response = request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8); back = reader.ReadToEnd(); reader.Close(); reader.Dispose(); response.Close(); } catch(Exception ex){ back = ex.Message; } return back; }
0 1
- c# .net 4.0 HttpWebRequest 访问https TLS1.2 解决方案
- C# httpwebrequest访问HTTPS错误处理
- .net2.0用TLS1.2+TCP Stream访问https网站
- 发送基于TLS1.2的HTTPS请求
- C#、VB.NET使用HttpWebRequest访问https地址(SSL)的实现方法
- C# HttpWebRequest人异步访问
- .Net HttpWebRequest 方式 访问服务器
- C# HttpWebRequest GET HTTP HTTPS 请求
- 小程序wx.request https TLS1.2环境配置
- https HttpWebRequest
- 关于Android4.x系统支持TLS1.2的解决方案
- C# HttpWebRequest访问页面时自动识别编码
- C# 访问Https
- window中的tls1.0、tls1.1、tls1.2启用方法!
- .net/C# HttpWebRequest传送与接收参数
- 在C#用HttpWebRequest中发送GET/HTTP/HTTPS请求
- 在C#用HttpWebRequest中发送GET/HTTP/HTTPS请求
- 在C#用HttpWebRequest中发送GET/HTTP/HTTPS请求
- 责任链--基本模式
- hdu 3336 Count the string(next数组+dp)
- TCHAR赋值和比较的问题
- 归档错误
- Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- c# .net 4.0 HttpWebRequest 访问https TLS1.2 解决方案
- 数据库(一)
- MFC中MessageBox置于顶层的问题
- ReadProcessMemory函数读取基址时输出却变成了一个地址,请教一下大家
- hashCode 和 equals
- Static变量的怪现象?
- 关于树形控件和组合框的问题~
- CListCtrl插入数据时滑动条的问题,请用过的朋友进来看看!
- php 函数