C#WebClient下载字符串https

Plo*_*der 5 .net c# xamarin.ios

在webbrowser中我通常可以加载以下url: https://security.ultimatxxxx.com:443/Serverstatus.ashx

当我这样做时:

Webclient.DownloadStringAsync("https://security.ultimatxxxx.com:443/Serverstatus.ashx");
Run Code Online (Sandbox Code Playgroud)

出于测试目的,您可以调用:ultimate-eur而不是ultimatxxxx.

它不起作用,但是当我加载没有https的普通URL时我没有问题.我必须添加哪个参数,以便Webclient也可以下载字符串?

我想在Monotouch中使用该功能,但语言是C#.

Dav*_*ish 8

如果您只想接受所有证书,则在提出请求之前,您需要设置证书检查:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
Run Code Online (Sandbox Code Playgroud)

这将接受所有证书.

虽然 - 如果您需要实际检查证书,请执行以下操作:

ServicePointManager.ServerCertificateValidationCallback =
    (sender, certificate, chain, sslPolicyErrors) => 
    {
        //to check certificate
    };
Run Code Online (Sandbox Code Playgroud)