简体   繁体   English

WebClient代理Https问题

[英]WebClient Proxy Https Issue

I've read allot about issues over SSL using proxy and i think its cause of the ssl certificate validation. 我已经阅读了有关使用代理服务器通过SSL的问题的分配,并且我认为这是SSL证书验证的原因。 But i have tested different methods to set it to always accept SSL without success. 但是我测试了不同的方法来将其设置为始终接受SSL而不成功。 My code works fine for HTTP but for HTTPS it "hangs"on connect and then fails. 我的代码适用于HTTP,但对于HTTPS而言,它在连接时“挂起”,然后失败。

My code: 我的代码:

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

The issue is that the website www.mittip.se does not work via https try these links. 问题是www.mittip.se网站无法通过https尝试这些链接。

http HTTP

https HTTPS

This isn't due to the certitifate, it's simply a case of the server not listening for https, unfortunately there is nothing you do in the code can make the website respond on https. 这不是由于证书引起的,这只是服务器不监听https的情况,不幸的是,您在代码中所做的任何操作都无法使网站在https上响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM