2

I've written a C# app that performs web requests via the System.Net.Http.HttpClient (e.g. client.GetAsync(uri);). Compiling and executing it with the .Net runtime, all these calls are successful. However, compiling and running with Mono, they fail with exceptions ("IOException Authentication or decryption failed").

However, switching to a network that doesn't go through the proxy resolves the issue. So in conclusion, it's not a certificate or whatever issue, but just the issue of the proxy.

Same applies for the tlstest tool: Fails miserably with the proxy, works fine without it.

How do I configure mono to use the proxy settings / use the system proxy settings?

stefan
  • 10,215
  • 4
  • 49
  • 90
  • Maybe related to this: http://stackoverflow.com/a/21291774/3508004. In Mono, there is no Windows Certificate store. – mtheriault Dec 12 '16 at 23:02
  • @mtheriault the certificates are (in general) an issue with mono, but this is not the source of problems here, as I already correctly deal with this. – stefan Dec 12 '16 at 23:09

2 Answers2

1

Can you try setting the proxy in HttpClient? You can set proxy credentials if necessary.

    WebProxy proxy = new WebProxy("proxyaddress", port);

    HttpClientHandler handler = new HttpClientHandler()
    {
        Proxy = proxy
    };

    HttpClient client = new HttpClient(handler);
Terry Lennox
  • 29,471
  • 5
  • 28
  • 40
  • That's not really a desirable solution. The issue definitely lies in Mono, so developing my App such that it awfully doesn't respect system proxy setting just sucks. But thanks anyway – stefan Dec 09 '16 at 09:14
0

Try to use modernhttpclient component. This library brings the latest platform-specific networking libraries to Xamarin applications via a custom HttpClient handler which can handle for you this kind of issues.

ivamax9
  • 2,601
  • 24
  • 33