HttpWebRequest 请求HTTPS协议时报错:The requested security protocol is not supported. (不支持请求的安全协议)
public String Get(string url, byte[] data){HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);try{//服务器需安装.net4.5,否则报错:The requested security protocol is not supported. (不支持请求的安全协议)ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;//SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;req.ProtocolVersion = HttpVersion.Version11;req.Method = "POST";req.KeepAlive = false;//req.Timeout = 1200000;req.ContentType = "application/x-www-form-urlencoded;charset=utf-8";//req.Headers.Add("ContentType", "application/x-www-form-urlencoded");req.Headers.Add("appKey", appKey);req.Headers.Add("appSecret", appSecret);req.ContentLength = data.Length;using (Stream reqStream = req.GetRequestStream()){reqStream.Write(data, 0, data.Length);}using (WebResponse response = req.GetResponse()){string text = "";using (Stream responseStm = response.GetResponseStream()){StreamReader redStm = new StreamReader(responseStm, Encoding.UTF8);text = redStm.ReadToEnd();}response.Close();//response = null;req.Abort();return text;}}catch (Exception ex){if (ex.InnerException != null){HttpContext.Current.Response.Write("内部错误信息:" + ex.InnerException.Message + "<br>");}req.Abort();throw ex;}return string.Empty;}
错误1:The requested security protocol is not supported. (不支持请求的安全协议)
原因:因为服务器上需安装.net4.5,(如果无效可以尝试重装IIS)
错误2:The remote name could not be resolved: 'nginx.platform.xxxxxx.cn'
原因:服务器无法解析这个域名,需要配置DNS解析
HttpWebRequest 请求HTTPS协议时报错:The requested security protocol is not supported. (不支持请求的安全协议)相关推荐
- 请求https接口时报错:Caused by SSLError(SSLError(1, u‘[SSL: CERTIFICATE_VERIFY_FAILED] certificat,安装certifi
标题 请求https接口时报错:Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificat,安装certi ...
- 服务启动时报错:1053服务没有及时响应启动或控制请求
问题:替换dll文件后,自定义服务启动时报错:1053服务没有及时响应启动或控制请求 排查原因:可能是程序启动缺少某些dll文件 解决方案:1.使用depends依赖工具查看新增的dll文件是否缺少哪 ...
- Docker发布镜像时报错denied: requested access to the resource is denied解决办法
当docker push时报如下错误: denied: requested access to the resource is denied 存在两种可能性: 1. docker未登录 解决方法:do ...
- Apex运行时报错提示“easy anti-cheat”“Game Security Violation Detected(#0000000D)[xxx.exe]“ 问题解决方案
Apex运行时报错提示"Game Security Violation Detected(#0000000D)[xxx.exe]" 问题解决方案 1.问题分析 某天加载游戏突然失败 ...
- 接口测试自动化之坑二:如何使用requests库请求https协议,解决提示报错和Unverified HTTPS request警告warning问题
1.首先在请求的requests中增加一条verify=False设置次参数的目的是跳过SSL证书问题 2.设置步骤一后,控制台会有Unverified HTTPS request报错信息 解决办法: ...
- SQL SERVER 2008筛选时报错 无法为该请求检索数据
使用SqlServer2008的筛选功能时报错"无法为该请求检索数据. (Microsoft.SqlServer.Management.Sdk.Sfc)" 如下图: 解决方法: 打 ...
- 解决vscode进行chrome调试时报错:localhost拒绝了我们的连接请求
解决vscode进行chrome调试时报错:localhost拒绝了我们的连接请求 只是为了记录,参考博客https://blog.csdn.net/LiBlacksmith/article/deta ...
- 解决git在push时报错fatal: unable to access ‘https://github.com/sup0C/a.git/‘: errno 10054
解决git在push时报错fatal: unable to access 'https://github.com/sup0C/a-repository-for--git/': OpenSSL SSL_ ...
- 解决wget下载https时报错
错误信息 -2021-10-11 07:09:45-- https://libvirt.org/sources/libvirt-4.7.0.tar.xz Resolving libvirt.org ( ...
最新文章
- VBScripts and UAC elevation(visa以后的系统)
- spring mvc框架设计与实现
- pyrealsense2 frame_metadata_value类(帧的元数据)(帧的元数据指可能针对每个单独的帧公开的一组只读属性)
- OpenGL绘制五颜六色的三角形并旋转
- 动态“神还原”李焕英旧照,用技术致敬每一位妈妈!
- Panoptic Segmentation论文笔记
- js学习 字符串常用方法
- python编程胡牌将是什么意思_python麻将和牌算法
- lz0-007 读书笔记11
- Spring框架----IOC的概念和作用之工厂模式
- zabbix api python使用
- HTTP协议的请求与响应和CSS属性和定位
- 【对讲机的那点事】无线电对讲系统在隧道中的应用
- CodeForces1005D - Polycarp and Div 3
- centos 6.4 使用sendmail发送邮件(cacti)
- 加入云上江湖—蚂蚁 SOFAStack
- python 比较数字大小_Python:整数比较大小和输出 | 学步园
- Fork\Join分而治之--RecursiveTask和RecursiveAction(一)
- 帖子浏览定位展开、收起标签js部分思路及代码
- 肖申克的救赎 -Hope