C#Web客户端下载地址字符串HTTPS [英] C# WebClient Download String https
问题描述
在web浏览器,我可以正常加载以下网址:
https://security.ultimatxxxx.com:443/Serverstatus.ashx
In the webbrowser I can normally load the following url:
https://security.ultimatxxxx.com:443/Serverstatus.ashx
当我做它:
Webclient.DownloadStringAsync("https://security.ultimatxxxx.com:443/Serverstatus.ashx");
有关测试的目的,您可以拨打:终极-欧元
而不是 ultimatxxxx
For testing purposes you can call: ultimate-eur
instead of ultimatxxxx
.
这是不行的,但是当我打开一个正常的URL没有HTTPS的,我没有问题。 这说法我必须补充,使Web客户端还可以下载该字符串?
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?
我想使用MonoTouch的该功能,但语言是C#。
I want to use that feature in Monotouch, but language is C#.
推荐答案
如果你只是希望接受所有的证书,您需要设置证书检查,你让你的请求之前:
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; };
这会接受所有证书。
虽然 - 如果你需要实际检查证书做这样的事情:
Although - if you need to actually check the certificate do something like:
ServicePointManager.ServerCertificateValidationCallback =
(sender, certificate, chain, sslPolicyErrors) =>
{
//to check certificate
};
这篇关于C#Web客户端下载地址字符串HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!