当前位置 博文首页 > 文章内容

    访问https接口报错 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系:dengqiu2187的博客

    作者:shunshunshun18 栏目:未分类 时间:2021-10-17 21:01:54

    本站于2023年9月4日。收到“大连君*****咨询有限公司”通知
    说我们IIS7站长博客,有一篇博文用了他们的图片。
    要求我们给他们一张图片6000元。要不然法院告我们

    为避免不必要的麻烦,IIS7站长博客,全站内容图片下架、并积极应诉
    博文内容全部不再显示,请需要相关资讯的站长朋友到必应搜索。谢谢!

    另祝:版权碰瓷诈骗团伙,早日弃暗投明。

    相关新闻:借版权之名、行诈骗之实,周某因犯诈骗罪被判处有期徒刑十一年六个月

    叹!百花齐放的时代,渐行渐远!



    推荐 IIS7批量FTP管理工具 IIS7批量FTP管理
    IIS7批量FTP管理功能说明:
    1、可批量导入,导出FTP信息
    2、其他ftp工具有的功能,我们也有
    3、特色功能:可以定时上传下载
    4、数据信息列表化、一眼就能知道那个是那个
    5、批量连接 标签页式切换 方便快捷
    6、7大连接模式 更多好的兼容
    7、内嵌编辑器 有效解决普通txt记事本乱码
    8、锁屏功能 当程序有规定时间内没人操作,则自动锁程序。输入密码才可以正常操作

    本产品适用于:懒得记录FTP信息和有批量定时备份,上传下载的运维或站长。

    图:


    IIS7批量FTP管理

    详细错误信息如下

    请求错误信息:发生一个或多个错误。System.Net.Http.HttpRequestException: An error occurred while sending the request. --->
    System.Net.WebException: 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系。 ---> System.Security.Authentication.AuthenticationException: 根据验证过程,远程证书无效。
    在 System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
    在 System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
    --- 内部异常堆栈跟踪的结尾 ---
    在 System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
    在 System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
    --- 内部异常堆栈跟踪的结尾 ---

     

    原本这个接口是http协议的,后来第三方为了安全使用了https协议?

    致使我的方法不支持https访问而报错?

     

    我原本的调用方法如下

            public static string Post(string httpUrl, string requestJson, ref List<string[]> msg, string source)
            {
                string strRet = string.Empty;
                int doop = 1;
                HttpResponseMessage response = new HttpResponseMessage();
                do
                {
                    if (doop != 1)
                        Thread.Sleep(60000);
                    try
                    {
                        using (var client = new HttpClient())
                        {
                            HttpContent httpContent = new StringContent(requestJson);
                            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                            response = client.PostAsync(httpUrl, httpContent).Result;
                            if (response.IsSuccessStatusCode)
                            {
                                strRet = response.Content.ReadAsStringAsync().Result;
                                msg.Add(new string[] { "Success", "post 发送的第" + doop + "次请求数据[" + httpUrl + "],[" + requestJson + "]" });
                            }
                            else
                            {
                                msg.Add(new string[] { "Error","post 的第" + doop + "次请求失败,数据[" + httpUrl + "],[" + requestJson + "]" + "\n"
                                + "请求错误信息:" + response.ReasonPhrase });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        strRet = string.Empty;
                        msg.Add(new string[] { "Error","post 发送的第" + doop + "次请求数据[" + httpUrl + "],[" + requestJson + "]" + "\n"
                            + "请求错误信息:" + ex.Message + ex.InnerException });
                    }
                    doop++;
                }
                while (doop <= 10 && !response.IsSuccessStatusCode);
                return strRet;
            }
    cs