我正在编写一个程序,用于从用户提供的URL中读取内容.我的问题在于代码是这样的:
Uri uri = new Uri(url);
WebRequest webRequest = WebRequest.Create(uri);
WebResponse webResponse = webRequest.GetResponse();
ReadFrom(webResponse.GetResponseStream());
Run Code Online (Sandbox Code Playgroud)
如果提供的URL是"https://"URL,则会中断.任何人都可以帮助我更改此代码,以便它可以使用SSL加密的内容.谢谢.
我有一个.NET客户端应用程序,尝试将文件ftp到ftp站点,该站点具有自签名SSL证书.此ftp站点在Windows 7 Enterprise,IIS 7上运行.我收到以下错误:"远程证书根据验证过程无效".
我已尝试在受信任的根证书中安装证书,但仍然无效.
我在代码中使用了委托回调,这里提到了一些帖子 - 它有效.但我不想在我的生产代码中使用它.
同样在生产中,我们的一些客户使用自签名证书.
有关如何解决此问题的任何想法?
我正在尝试使用以编程方式发送电子邮件SmtpClient.Send.我正在AuthenticationException尝试发送电子邮件.这是因为证书验证程序失败.
我知道证书是正确的,但我也理解,信任所有证书并不安全,就像这样做的建议:
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => { return true; };
Run Code Online (Sandbox Code Playgroud)
所以我想知道测试Thumbprint已知的有效证书指纹是否足够安全,如下所示:
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) =>
{
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
else if (certificate.GetCertHashString().Equals("B1248012B10248012B"))
return true;
return false;
};
Run Code Online (Sandbox Code Playgroud)