在用HttpClient发起https请求时,遭遇了“The remote certificate is invalid according to the validation procedure”异常,异常信息如下:

Exception Details: System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

[AuthenticationException: The remote certificate is invalid according to the validation procedure.]
System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) +8622023
System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar) +225 [WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.]
System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) +3564749
System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) +155

HttpClient调用代码如下:

var httpClient = new HttpClient();
var httpContent = new FormUrlEncodedContent(new
Dictionary<string, string>
{
{"grant_type", "client_credentials"}
});
var response = await httpClient.PostAsync("https://...", httpContent);

解决方法:

在web.config中添加如下的配置:

<system.net>
<settings>
<servicePointManager checkCertificateName="false" checkCertificateRevocationList="false" />
</settings>
</system.net>

解决“The remote certificate is invalid according to the validation procedure”问题的更多相关文章

  1. The remote certificate is invalid according to the validation procedure 远程证书验证无效

    The remote certificate is invalid according to the validation procedure   根据验证过程中远程证书无效 I'm calling ...

  2. (转)The remote certificate is invalid according to the validation procedure

    If you get “The remote certificate is invalid according to the validation procedure” exception while ...

  3. .net core中Grpc使用报错:The remote certificate is invalid according to the validation procedure.

    因为Grpc采用HTTP/2作为通信协议,默认采用LTS/SSL加密方式传输,比如使用.net core启动一个服务端(被调用方)时: public static IHostBuilder Creat ...

  4. 异常处理之“The remote certificate is invalid according to the validation praocedure.”

    参考文章:http://brainof-dave.blogspot.com.au/2008/08/remote-certificate-is-invalid-according.html 参考文章:h ...

  5. use AP_VENDOR_PUB_PKG.Update_Vendor_Site_Public to u ORA-01722: invalid number in Package AP_VENDOR_PUB_PKG Procedure Update_Vendor_Site_Public

    ORA-01722: invalid number in Package AP_VENDOR_PUB_PKG Procedure Update_Vendor_Site_Public 发现此问题的经过: ...

  6. 解决MAC下xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)的问题

    将系统升级到了最新10.13.3 macOS High Sierra后,在使用ctags命令时会出现如下问题: xcrun: error: invalid active developer path ...

  7. 解决WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

    问题: 当我想要利用win10本地的cmd进行: ssh root@192.168.1.230 时,出现了如下错误: C:\Users\Raodi>ssh root@192.168.1.230 ...

  8. 解决cvc-complex-type.2.4.a: Invalid content was found starting with element

    今天用myeclipse导入 一个项目出现后出现cvc-complex-type.2.4.a: Invalid content was found starting with element 'inf ...

  9. 解决"The remote SSH server rejected X11 forwarding request"问题

    今天突然想起来好久没有登录我的vps了,于是下载了xshell,填入地址登录后,看到提示"WARNING! The remote SSH server rejected X11 forwar ...

随机推荐

  1. e555. 在Applet中播放音频

    // See also e551 精简的Applet public void init() { // Load audio clip AudioClip ac = getAudioClip(getDo ...

  2. 类的数据成员加前缀 m_(表示 member)

    类的数据成员加前缀 m_(表示 member),这样可以避免数据成员与 成员函数的参数同名. 例如: void Object::SetValue(int width, int height) { m_ ...

  3. Huffman树

    结点定义: /* * Huffman树结点定义 */ struct Node { ElementType weight; // 结点的权值 struct Node *leftChild; // 结点的 ...

  4. PHP清除HTML代码、空格、回车换行符的函数

    清除HTML代码.空格.回车换行符的函数如下 function DeleteHtml($str) { $str = trim($str); $str = strip_tags($str,"& ...

  5. HBase复制

    HBase复制是一种在不同HBase部署中复制数据的方法.它能够作为一种故障恢复的方法,并提供HBase层次的高可用性.在实际应用中,比如.能够将数据从一个面向页面的集群拷贝到一个MapReduce集 ...

  6. 如何通过phoenix中查看表的主键信息

    需求描述: 今天一个开发的同事让帮忙查看下表的主键列,在此记录下. 操作过程: 1.通过!primarykeys命令查看表的主键 !primarykeys SYNC_BUSINESS_INFO_BYD ...

  7. 第四章 Spring.Net 如何管理您的类___自定义对象行为

    Spring.Net 一直讲求 ” 配置应用程序“,有一种需求在实际开发中不太常用,却非常有用 -> 配置对象的行为,Spring.Net 也能够完美的实现.Spring.Net 通过几个专门的 ...

  8. 在(MRv1)中JobTracker工作方式

    在 Hadoop MapReduce 中,JobTracker 具有两种不同的职责: 管理集群中的计算资源,这涉及到维护活动节点列表.可用和占用的 map 和 reduce slots 列表,以及依据 ...

  9. php 升级后 htmlspecialchars 返回空 的解决方案

    今天将php版本升级到5.3.0以上(我升级到php5.4.13)的版本后发现一个问题 htmlspecialchars 函数返回为空.查了资料后,发现新版本对htmlspecialchars这个函数 ...

  10. 安装postgresql之后为什么找不到postgresql service

    没有正常启动 postgresql service.可以 在运行里面 输入 services.msc 找到 postgresql 的服务.启动他.或者也可以用postgres 自带的 工具pg_ctl ...