[英]Error: Could not create SSL/TLS secure channel Windows 8
After upgrading to Windows 8, I am having problems with a web service call that was previously working. 升级到Windows 8后,以前无法正常使用的Web服务调用出现问题。 I've already verified on two Windows 8.1 machines and one Windows 8 machine that the following code fails, but it works without error on Windows 7 and Windows Server 2008 R2.
我已经在两台Windows 8.1机器和一台Windows 8机器上验证以下代码失败,但是在Windows 7和Windows Server 2008 R2上它可以正常工作。
var uriString = "https://secure.unitedmileageplus.com/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uriString);
try {
using(WebResponse response = request.GetResponse()) {
response.Dump();
}
}
catch(Exception e) {
e.Dump();
}
WebException The request was aborted: Could not create SSL/TLS secure channel.
WebException请求已中止:无法创建SSL / TLS安全通道。
It seems to be localized to this endpoint, as I am able to successfully make SSL calls to other URLS. 它似乎已本地化到此端点,因为我能够成功地对其他URL进行SSL调用。 I've done some Wireshark sniffing already, but not knowing what to look for, it wasn't much help.
我已经做了一些Wireshark嗅探,但是不知道要寻找什么,它并没有太大帮助。 Let me know if you'd like me to provide those logs as well.
让我知道您是否也希望提供这些日志。
WebRequest
set TLS/SSL version to TLS 1.0 by default. WebRequest
默认将TLS / SSL版本设置为TLS 1.0。 You can set it back to SSL 3.0 using ServicePointManager.SecurityProtocol
. 您可以使用
ServicePointManager.SecurityProtocol
将其设置回SSL 3.0。 Eg: 例如:
static void Main(string[] args)
{
var uriString = "https://secure.unitedmileageplus.com/";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uriString);
ServicePointManager.ServerCertificateValidationCallback =
new RemoteCertificateValidationCallback(AcceptAllCertifications);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
try
{
using (WebResponse response = request.GetResponse())
{
Debug.WriteLine(response);
}
}
catch (Exception e)
{
Debug.WriteLine(e);
}
}
public static bool AcceptAllCertifications(
object sender,
System.Security.Cryptography.X509Certificates.X509Certificate certification,
System.Security.Cryptography.X509Certificates.X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.