我有以下代码,这会导致 WebException 并且我无法弄清楚为什么我的生活。Windows 8 RTM 上的 VS2012 / .Net 4.5 RTM。
ServicePointManager.CertificatePolicy = null;
ServicePointManager.CheckCertificateRevocationList = false;
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
var request = WebRequest.Create(url) as HttpWebRequest;
request.ServerCertificateValidationCallback = delegate { return true; };
var response = request.GetResponse();
WebException was unhandled
The request was aborted: Could not create SSL/TLS secure channel.
我最初将回调作为自己的方法,从未调用过。有什么想法为什么我无法忽略 SSL 验证错误并将所有敏感数据发送到未知的 Web 服务器?