WebRequestHandler handler = new WebRequestHandler();
try
{
X509Certificate2 certificate = new X509Certificate2(System.IO.File.ReadAllBytes(ConfigurationManager.AppSettings["webapicertpath"]), ConfigurationManager.AppSettings["webapicertpwd"]); ;
handler.ClientCertificates.Add(certificate);
ServicePointManager.ServerCertificateValidationCallback =
(object sender, X509Certificate certificate1, X509Chain chain, SslPolicyErrors sslPolicyErrors) =>
{
return true;
};
}
catch
{
}
httpClient = new HttpClient(handler);

  to fetch data with REST httpclient, just utilize code below:

                case "get":
result = httpClient.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
break;
case "post":
result = httpClient.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
break;
case "put":
result = httpClient.PutAsync(url, content).Result.Content.ReadAsStringAsync().Result;
break;
case "delete":
result = httpClient.DeleteAsync(url).Result.Content.ReadAsStringAsync().Result;
break;
default:
break;

  

utilize HttpClient to generate a SSL access and generate REST access to fetch data, async programming? cool and brief的更多相关文章

  1. Configuring Squid as an accelerator/SSL offload for Outlook Web Access

    reference:http://wiki.squid-cache.org/SquidFaq/ReverseProxy/ Configuring Squid as an accelerator/SSL ...

  2. Access之C#连接Access

    原文:Access之C#连接Access 如果是个人用的小程序的话.一般都推荐用Sqlite和Access 使用SQlite数据库需要安装SQLite驱动,详情:SQLite之C#连接SQLite 同 ...

  3. Access数据库SQL注入(Access SQL Injection)

    一.Microsoft Office Access数据库手工注入语句  1.参数后面加  ’ .and 1=1.and 1=2看返回状态判断是否存在注入点 2.参数后面加 and exists(sel ...

  4. You may experience an access violation when you access an STL object through a pointer or reference in a different DLL or EXE

    Symptoms When accessing an STL object created in one DLL or EXE through a pointer or reference in a ...

  5. nginx的access的阶段的access模块、auth_basic模块、auth_request模块及satisfy指令介绍

    access 模块 示例从上向下匹配 location / { deny 192.168.1.1; allow 192.168.1.0/24; allow 10.1.1.0/16; allow 200 ...

  6. HttpClient忽略SSL证书

    今天公司项目请求一个接口地址是ip格式的,如:https://120.20.xx.xxx/xx/xx,报一个SSL的错: 由于之前请求的接口地址都是域名地址,如:https://www.xxx.com ...

  7. HttpClient SSL connection could not be established error

    系统从.net framework 升级到dotnet core2.1 原先工作正常的httpclient,会报SSL connection could not be established erro ...

  8. 你想要了解但是却羞于发问的有关SSL的一切

    Everything You Ever Wanted to Know About SSL (but Were Afraid to Ask) Or perhaps more accurately, &q ...

  9. Oracle Applications Multiple Organizations Access Control for Custom Code

    档 ID 420787.1 White Paper Oracle Applications Multiple Organizations Access Control for Custom Code ...

随机推荐

  1. c#List结合IEqualityComparer求交集

    List元素类: public class MultiPointSearchingRet { public int ID { get; set; } public string PlateNumber ...

  2. fei33423 工作 职场 格言

    对老板: 1.  老板不知道你做的事情(目标设定) 2.  老板要的是规划(对上报告), 自己给自己设定 金字塔四位下的目标,各种维度.如何细化. 2.1 明确老板期望 2.2 与老板达成共识 2.3 ...

  3. 在Linux系统中重现黑客帝国经典画面

    我们需要一个叫cmatrix的小程序,下面写出步骤 1 :依赖环境  yum -y install gcc ncurses-devel 2 :下载程序  wget https://files.cnbl ...

  4. python GIL锁、进程池与线程池、同步异步

    一.GIL全局解释器锁 全局解释器锁 在CPython中,全局解释器锁(GIL)是一个互斥锁,它可以防止多个本机线程同时执行Python代码.之所以需要这个锁,主要是因为CPython的内存管理不是线 ...

  5. 用session模拟登陆,手动输入验证码

    # 本练习是模拟登陆及验证码处理(把验证码下载到本地后手动输入) # 1 通过分析页面获得form表单的登陆接口为 action="https://www.douban.com/accoun ...

  6. LeetCode(268) Missing Number

    题目 Given an array containing n distinct numbers taken from 0, 1, 2, -, n, find the one that is missi ...

  7. LeetCode(292) Nim Game

    题目 You are playing the following Nim Game with your friend: There is a heap of stones on the table, ...

  8. Ubuntu下安装anaconda和pycharm

    折腾了一上午,终于装好了,如下:Python环境的安装: 安装anaconda 建议去https://www.anaconda.com/download/#linux直接用Ubuntu界面的搜狐浏览器 ...

  9. JS实现——俄罗斯方块

    把以下代码保存成Tetris.html文件,使用Google或360浏览器打开 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 4.0 Transit ...

  10. kafka消息的可靠性

    本文来自网易云社区 作者:田宏增 Kafka的高可靠性的保障来源于其健壮的副本(replication)策略.通过调节其副本相关参数,可以使得Kafka在性能和可靠性之间运转的游刃有余.Kafka从0 ...