net 调用https接口
public static void ProcessRequest()
{
//类似浏览器确认证书合法方法的绑定
ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://aaaaaa.com/getToken?");
string param = "userName=abc&type=123";
byte[] bs = Encoding.UTF8.GetBytes(param);
request.Method = "post";
using (Stream reqStram = request.GetRequestStream())
{
reqStram.Write(bs, 0, bs.Length);
}
string strResponse = "";
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
strResponse = reader.ReadToEnd();
}
}
Console.ReadKey();
}
//该方法用于验证服务器证书是否合法,当然可以直接返回true来表示验证永远通过。服务器证书具体内容在参数certificate中。可根据个人需求验证
//该方法在request.GetResponse()时触发
private static bool RemoteCertificateValidate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
{
//为了通过证书验证,总是返回true
return true;
}
net 调用https接口的更多相关文章
- delphi调用https接口
delphi调用http接口直接使用idhttp就可以了,但是调用https接口的时候就需要和IdSSLIOHandlerSocket1控件一起使用. 截图中是两个控件的具体配置,需要注意的是IdSS ...
- JAVA 调用https接口, java.security.cert.CertificateException
package com.easycare.store.util; import java.security.cert.CertificateException; import java.securit ...
- 【IoT平台北向API调用】使用Postman调用Https接口
1. Download and install postman https://www.getpostman.com/ Version:the version I download is Postma ...
- 用curl调用https接口
今天在windows下用curl类获取微信token一直返回false,查阅资料后,发现是https证书的锅,在curl类中加上这两条,问题瞬间解决. curl_setopt($ch, CURLOPT ...
- Java调用HTTPS接口的证书配置
首先需要获取到证书文件. 然后,将证书导入到本地: keytool -import -noprompt -trustcacerts -alias <AliasName> -file < ...
- Java调用Http/Https接口(7,end)--WebClient调用Http/Https接口
WebClient是Spring提供的非阻塞.响应式的Http客户端,提供同步及异步的API,将会代替RestTemplate及AsyncRestTemplate.文中所使用到的软件版本:Java 1 ...
- Java调用Http/Https接口(6)--RestTemplate调用Http/Https接口
RestTemplate是Spring提供的用于访问Http接口的客户端,提供同步的API:在将来的Spring版本中可能会过时,将逐渐被WebClient替代.文中所使用到的软件版本:Java 1. ...
- Java调用Http/Https接口(5)--HttpAsyncClient调用Http/Https接口
HttpAsyncClient是HttpClient的异步版本,提供异步调用的api.文中所使用到的软件版本:Java 1.8.0_191.HttpClient 4.1.4. 1.服务端 参见Java ...
- Java调用Http/Https接口(4)--HttpClient调用Http/Https接口
HttpClient是Apache HttpComponents项目下的一个组件,是Commons-HttpClient的升级版,两者api调用写法也很类似.文中所使用到的软件版本:Java 1.8. ...
随机推荐
- CAN总线(一)
原文出处:http://www.cnblogs.com/jacklu/p/4729638.html 嵌入式的工程师一般都知道CAN总线广泛应用到汽车中,其实船舰电子设备通信也广泛使用CAN,随着国家对 ...
- java的for循环冒号
背景:有一个小伙纸问我 下面的java代码是什么意思. for (final RouterInterface routeIface : curNode.getRouteInterfaces()){ … ...
- CSS基础01
1.line-height:设置每行的高度,默认是会以文字的高度来决定 2.text-align:设置文本的对齐方式 3.vertical-align: sub 垂直对齐文本的下标. super 垂直 ...
- SRM 146 DIV1 800
Problem Statement The purpose of a roundabout is to control the flow of traffic at a busy inter ...
- nodeJs中创建服务器
var http=require('http'); var httpObj=http.createServer(function(req,res) { console.log('someBody:' ...
- 2016 Multi-University Training Contest 2 - 1005 Eureka
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5738 题目大意:给定平面上的n个点,一个集合合法当且仅当集合中存在一对点u,v,对于集合中任意点w,均 ...
- sql 2012日志文件频繁出现:svchost (4892) 数据库引擎已分离数据库(1、C:\Windows\system32\LogFiles\Sum\Current.mdb)
svchost (4892) 数据库引擎已分离数据库(1.C:\Windows\system32\LogFiles\Sum\Current.mdb).(时间=0 秒) 内部计时序列: [1] 0.00 ...
- ORACLE连接SQLSERVER
一.实验(实验成功) 1.实验目标:ORACLE连接SQLSERVER以及查询数据 2.搭建的环境: oracle 9i 9.0.2.0.1 地址:192.168.40.139 sql2000 的数据 ...
- U-Mail邮件网关提醒:谨防像素图片钓鱼窃密
垃圾邮件和病毒的日益猖獗,既因为邮件在商务往来中扮演着越来越重要的角色,也因为犯罪成本低收益高.近年来,不少为非作歹者致力于通过邮件诈骗牟利,想出了种种奇思妙计,导致相关服务商在安全领域逐年加大研发投 ...
- 收藏网址 ios开源库
http://www.csdn.net/article/2015-07-21/2825264-27-ios-open-source-libraries/1