问题
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