赞
踩
在谷歌浏览器中打开该链接,按下F12,打开开发者工具,切换到Security选项卡,就可以看到了。这一串说明:
The connection to this site is encrypted and authenticated using TLS 1.2, ECDHE_RSA with P-256, and AES_128_GCM.
就是 TLS1.2
各SSL版本与C#代码的对应:
SSL/TLS版本 | 对应C#代码 |
---|---|
SSL 3 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; |
TLS 1.0 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; |
TLS 1.1 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11; |
TLS 1.2 | ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; |
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
//如果编译器报错:未包含"Tls11"的定义,用以下代码,要解决这个报错也可以安装.net framework 4.5
//System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | (SecurityProtocolType)3072 | (SecurityProtocolType)768 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{ // 总是接受
return true;
});//验证服务器证书回调自动验证
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。