Error: Could not create SSL/TLS secure channel Windows 8

六眼飞鱼酱① 提交于 2020-01-05 04:15:34

问题


After upgrading to Windows 8, I am having problems with a web service call that was previously working. 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.

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.

It seems to be localized to this endpoint, as I am able to successfully make SSL calls to other URLS. I've done some Wireshark sniffing already, but not knowing what to look for, it wasn't much help. Let me know if you'd like me to provide those logs as well.


回答1:


WebRequest set TLS/SSL version to TLS 1.0 by default. You can set it back to SSL 3.0 using ServicePointManager.SecurityProtocol. E.g.:

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;
}


来源:https://stackoverflow.com/questions/20228656/error-could-not-create-ssl-tls-secure-channel-windows-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!