C# HttpClient 带证书https 请求

https://blog.csdn.net/mgy_2601907/article/details/100988387

 


//导入证书
WebRequestHandler handler = new WebRequestHandler();
string certificateFileName = 此处为存储证书的路径//Config.Read("certificateFileName");
//根据指定证书文件创建证书
X509Certificate x509Certificate = X509Certificate.CreateFromCertFile(certificateFileName);
handler.ClientCertificates.Add(x509Certificate);

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
PS:在创建HttpClient之前加入此段代码即可
————————————————
版权声明:本文为CSDN博主「陌人青丝」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mgy_2601907/article/details/100988387

上一篇:Linux中du、df显示不一致问题


下一篇:C# 中HttpClient无法发送json对象