简体   繁体   中英

WebClient Proxy Https Issue

I've read allot about issues over SSL using proxy and i think its cause of the ssl certificate validation. But i have tested different methods to set it to always accept SSL without success. My code works fine for HTTP but for HTTPS it "hangs"on connect and then fails.

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.

http

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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