使用WebClient 发送https请求

使用WebClient发送请求时,并且是以https协议;

WebClient webClient = new WebClient();

string result = webClient.DownloadString(url);

error : The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

只需一行代码:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };//获取或设置用于验证服务器证书的回调。[SSL]

每个问题都有解决之法,遇到问题不要怕,解决问题才是提升最快的。

--------------------------------送给每天和bug打交道的博友们

Web Server 使用WebClient 发送https请求 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel的更多相关文章

  1. https请求时出错:Could not establish trust relationship for the SSL/TLS secure channel

    当我在用NET命名空间下获取URL的时候,提示如下错误: The underlying connection was closed: Could not establish trust relatio ...

  2. [HTTPS] - 请求API失败(Could not create SSL/TLS secure channel)之解决

    背景 在单元测试中请求 HTTPS API 失败. 异常 Result StackTrace:  at System.Web.Services.Protocols.WebClientProtocol. ...

  3. 请求被中止: 未能创建 SSL/TLS 安全通道,以及解决方法,即:Could not create SSL/TLS secure channel

    C# 访问https请求被中止: 未能创建 SSL/TLS 安全通道(Could not create SSL/TLS secure channel) 以及 X509Certificate2 temp ...

  4. 微信退款时候报”请求被中止: 未能创建 SSL/TLS 安全通道“或”The request was aborted: Could not create SSL/TLS secure channel“的错误

    如题,英文中文表述的是一个意思 退款测试在我本机测试一切都是正常的,但是发布到了服务器就报这样的一个错啦 但是无论百度或者google或者bing,你能够搜索到的结果都很类似,综合起来就是加这样一些代 ...

  5. visual studio Web发布至 IIS WebDeploy出错(未能创建SSL/TLS安全通道)Could not create SSL/TLS secure channel

    问题发生的原因是VS 15.9尝试使用系统默认值进行TLS握手,但是要在VS内的某处设置为TLS1.2. 此问题的解决方法是在部署项目的IIS服务器上启用TLS 1.2.例如,请按照此文章中的说明操作

  6. 【转】微信退款时候报”请求被中止: 未能创建 SSL/TLS 安全通道“或”The request was aborted: Could not create SSL/TLS secure channel“的错误

    退款测试在我本机测试一切都是正常的,但是发布到了服务器就报这样的一个错啦 但是无论百度或者google或者bing,你能够搜索到的结果都很类似,综合起来就是加这样一些代码,如下 ServicePoin ...

  7. 【传输协议】发送https请求,由于客户端jdk版本过高,服务端版本低。导致异常:javax.net.ssl.SSLHandshakeException: Server chose SSLv3, but that protocol version is not enabled or not supported by the client.

    本地环境jdk为1.8,服务器使用jdk版本未知.但发送https请求,抛出如下异常,解决方案. 一:发送异常内容如下 javax.net.ssl.SSLHandshakeException: Ser ...

  8. 使用HttpClient发送HTTPS请求以及配置Tomcat支持SSL

    这里使用的是HttpComponents-Client-4.1.2 package com.jadyer.util; import java.io.File; import java.io.FileI ...

  9. 【转载】JMeter学习(三十六)发送HTTPS请求

    Jmeter一般来说是压力测试的利器,最近想尝试jmeter和BeanShell进行接口测试.由于在云阅读接口测试的过程中需要进行登录操作,而登录请求是HTTPS协议.这就需要对jmeter进行设置. ...

随机推荐

  1. android 后台代码设置动画

    1.设置旋转动画 final RotateAnimation animation =new RotateAnimation(0f,360f,Animation.RELATIVE_TO_SELF, 0. ...

  2. 解决jquery-easyui1.3.3 combobox 多选模式不兼容IE8问题

    扩展Array的原型对象,加入indexOf方法 if(!Array.prototype.indexOf){    Array.prototype.indexOf = function(target) ...

  3. 图解SQL的Join(转摘)

    转摘网址:http://coolshell.cn/articles/3463.html 对于SQL的Join,在学习起来可能是比较乱的.我们知道,SQL的Join语法有很多inner的,有outer的 ...

  4. codeforce 421D D. Bug in Code

    题目链接: http://codeforces.com/problemset/problem/421/D D. Bug in Code time limit per test 1 secondmemo ...

  5. HDU 5647 DZY Loves Connecting 树形dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5647 题解: 令dp[u][0]表示u所在的子树中所有的包含i的集合数,设u的儿子为vi,则易知dp ...

  6. 802.11 wireless 三

    802.11 wireless 3watts,milliwatts,and Decibels瓦特(功率单位)的定义是1焦耳/秒微波炉1000瓦特,手机100-200毫瓦 decibels(分贝:比较能 ...

  7. 设计模式之外观模式(Facade)

    外观模式原理:将复杂的子系统的结构封装起来,只提供客户一个简单的接口 代码如下: #include <iostream> #include <string> #include ...

  8. JavaScript原生折叠扩展收缩菜单带缓冲动画

    JavaScript原生折叠扩展收缩菜单带缓冲动画 @落雨 <div id="div_two" style="display: none;"> &l ...

  9. UML建模类型(转载)

    区分UML模型, UML建模用于不同类型的不同的图.有三个重要类型的UML建模: 结构建模: 系统结构建模捕捉静态功能.它们包括下列各项: 类图 对象图 部署图 包图 复合结构图 组件图 结构模型代表 ...

  10. javascript设计模式-迭代器模式(Iterator)

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...