赞
踩
- public static void SetCertificatePolicy()
- {
- System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
- ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidate;
- }
查阅资料好像说是Framework4.8有这个枚举,但是我安装不上。
如果确实需要这个安全类型的话,经过查阅资料发现我们可以使用带安全证书的形式进行访问。
- HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
- /*
- req 的其他属性的赋值
- */
- X509Certificate2 cer = new X509Certificate2("证书.p12文件路径", "证书密码", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable);
-
- req.ClientCertificates.Add(cer);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。