Bug in Mono !? WebRequest to a HTTPS resource with proxy fails to work

孤人 提交于 2019-12-11 09:21:55

问题


I have a proxy(Fiddler) setup and I created an Android app on Windows 10 x64 with latest Xamarin stable as of today, with the following code:

        IWebProxy proxy = new WebProxy("http://192.168.1.100:8888/");
        proxy.Credentials = new NetworkCredential("johndoe", "1234567890");
        WebRequest.DefaultWebProxy = proxy;

        var req = WebRequest.CreateHttp("https://www.google.com");
        req.GetResponse();

throws exception:

Unhandled Exception:

System.Net.WebException: Error: Success

If I change the request to non-secure URL: http://www.google.com it works fine!

I've found something which looks similar, not sure, here:

https://github.com/NuGet/Home/issues/3969

https://bugzilla.xamarin.com/show_bug.cgi?id=19594

Is there a workaround?

If I put same C# code in a console app, it works with both HTTPS and HTTP URLS so Fiddler is not an issue!

I even tried to set the proxy authorization header like this, but it didn't work:

req.Headers.Add(HttpRequestHeader.ProxyAuthorization, "Basic am9obmRvZToxMjM0NTY3ODkw");

来源:https://stackoverflow.com/questions/41520759/bug-in-mono-webrequest-to-a-https-resource-with-proxy-fails-to-work

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