Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WebClient代理Https问题_C#_Ssl_Webclient - Fatal编程技术网

C# WebClient代理Https问题

C# WebClient代理Https问题,c#,ssl,webclient,C#,Ssl,Webclient,我读过allot关于使用代理的SSL问题的文章,我认为这是SSL证书验证的原因。但我已经测试了不同的方法,将其设置为始终接受SSL,但没有成功。我的代码在HTTP上运行良好,但在HTTPS上它“挂起”在connect上,然后失败 我的代码: ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; string response; try

我读过allot关于使用代理的SSL问题的文章,我认为这是SSL证书验证的原因。但我已经测试了不同的方法,将其设置为始终接受SSL,但没有成功。我的代码在HTTP上运行良好,但在HTTPS上它“挂起”在connect上,然后失败

我的代码:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

string response;
            try
            {
                using (WebClient wc = new WebClient())
                {
                    var ProxyA = "192.168.0.103:8888".Split(':'); 
                    string PHost = ProxyA[0];
                    int PPort = Int32.Parse(ProxyA[1]);
                    wc.Proxy = new WebProxy(PHost, PPort);              
                    response = wc.DownloadString("https://www.mittip.se"); 

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

问题是网站www.mittip.se不能通过https工作,请尝试这些链接


这不是因为认证,这只是服务器未侦听https的情况,不幸的是,您在代码中所做的任何操作都无法使网站在https上响应。

谢谢!上面的示例代码只是我在使用SSL证书时编写的一些测试代码,正如您所说,它在SSL上不起作用。现在我用ServicePointManager.ServerCertificateValidationCallback=delegate{return true;}测试了我的旧代码;而且效果很好!非常感谢你!我的错!