C# WebClient Download String https

.net, c#, xamarin.ios

Solution

If you just wish to accept all certificates, you'll need to set certificate check, before you make your request:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

This will accept all certificates.

Although - if you need to actually check the certificate do something like:

ServicePointManager.ServerCertificateValidationCallback =
    (sender, certificate, chain, sslPolicyErrors) => 
    {
        //to check certificate
    };

Problem

In the webbrowser I can normally load the following url: `https://security.ultimatxxxx.com:443/Serverstatus.ashx` When I do it with: ``` Webclient.DownloadStringAsync("https://security.ultimatxxxx.com:443/Serverstatus.ashx"); ``` For testing purposes you can call: `ultimate-eur` instead of `ultimatxxxx`. It does not work, but when I load a normal URL without https I have no problems. Which argument do I have to add so that the Webclient can also download the string? I want to use that feature in Monotouch, but language is C#.

Original source