双向验证证书地址请求方式
【双向验证证书地址请求方式】url:请求地址
value:请求参数
cerPath:P12证书路径
password:证书密码
public static HttpResult PostRequest( string url, object value, string certPath, string password)
{
try
{
var parameters = JsonWrapper.SerializeObject(value);
byte[] data = https://www.it610.com/article/Encoding.UTF8.GetBytes(parameters);
var request = (HttpWebRequest)WebRequest.Create(url);
request.ContentLength = data.Length;
request.Headers.Add(“cache-control”, “no-cache”);
ServicePointManager.ServerCertificateValidationCallback
= new RemoteCertificateValidationCallback(CheckValidationResult);
X509Certificate cert = new X509Certificate(certPath, password, X509KeyStorageFlags.MachineKeySet);
request.ClientCertificates.Add(cert);
request.Method = “POST”;
request.ContentType = “application/json”;
var stream = request.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string content = reader.ReadToEnd();
return new HttpResult
{
StatusCode = response.StatusCode,
Data = https://www.it610.com/article/JsonWrapper.DeserializeObject(content)
};
}
catch (System.Exception e)
{
throw e;
}
}
推荐阅读
- Pytorch学习|sklearn-SVM 模型保存、交叉验证与网格搜索
- 劳协证书已出,如何办理劳协持证入户()
- 360|360 将停止 StartCom 数字证书业务;微软的 Visual Studio Tools for AI 现已提供使用
- 人工智能|【机器学习】深度盘点(详细介绍 Python 中的 7 种交叉验证方法!)
- 解决|解决 win 10 远程桌面身份验证错误问题
- macOS系统上,安装包安装权限不足或验证不过问题
- IC|数字IC后端真的不如前端设计和验证吗()
- RF接口返回数据验证举例
- Python【习题】(随机生成激活码、优惠码、验证码)
- 2020-08-13|2020-08-13 同花顺证书批量下载