C# Zipwise.com无法创建SSL/TLS安全通道

C# Zipwise.com无法创建SSL/TLS安全通道,c#,api,ssl,httpwebrequest,tls1.2,C#,Api,Ssl,Httpwebrequest,Tls1.2,我的应用程序遇到了问题。当试图使用ZipWise.com的api获取一些邮政编码时,我得到了一个错误“请求被中止:无法创建SSL/TLS安全通道”。我没有对程序进行任何更改,程序突然停止允许我使用他们的api。在创建请求之前,我尝试将其添加到代码的开头: ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 我在服务器上禁用

我的应用程序遇到了问题。当试图使用ZipWise.com的api获取一些邮政编码时,我得到了一个错误“请求被中止:无法创建SSL/TLS安全通道”。我没有对程序进行任何更改,程序突然停止允许我使用他们的api。在创建请求之前,我尝试将其添加到代码的开头:

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
我在服务器上禁用了TLS 1.0、TLS 1.1、SSL 2.0和SSL 3.0(并重新启动)。我能够在浏览器中打开url而不会出现问题。我在SSL实验室验证了他们使用的是TLS1.2

当我在我的开发PC上运行它时,它会毫无问题地执行并返回一组邮政编码。当我试图在服务器上运行它时,它失败了,并给我这个错误

下面是我在Windows窗体应用程序中使用的一些示例代码,它会产生相同的错误:

        private void button1_Click(object sender, EventArgs e)
    {
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        ServicePointManager.Expect100Continue = true;

        string url = "https://zipwise.com/webservices/radius.php?key=**********&zip=90210&radius=50";

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(url));
        request.Method = "POST";

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();//exception occurs here

        StreamReader input = null;
        XDocument doc = null;

        if (response.StatusCode.Equals(HttpStatusCode.OK))
        {
            input = new StreamReader(response.GetResponseStream());
            doc = XDocument.Parse(input.ReadToEnd());
        }

        response.Close();
        request.ServicePoint.CloseConnectionGroup(request.ConnectionGroupName);

        if (input != null)
        {
            input.Close();

            var tempZips = (from z in doc.Descendants("result") select z.Descendants("zip").Single().Value).ToList();
            finalZips.AddRange(tempZips);

            foreach(string s in finalZips)
            {
                listBox1.Items.Add(s);
            }
        }
    }
感谢您的帮助


编辑:应用程序正在.NET 4.6上运行,服务器上的SSL证书仍然有效。

是否更改了NET版本或重新编译了代码?证书仍然有效吗?忘了提一下,我使用的是.NET 4.6,是的,证书仍然有效。当NET使用证书更改加密时,人们遇到了问题。我以为是4.7,但也可能是4.6。我怀疑新的网络默认为64位,而旧的代码使用32位。尚未收到任何指示如何解决问题的响应。