【发布时间】:2013-03-11 09:43:23
【问题描述】:
我希望从任何给定的域名 SSL 证书中获取数据。例如,我想输入任何网站地址,例如“http://stackoverflow.com”,我的代码将首先检查 SSL 证书是否存在。如果是这样,那么我希望它提取证书的到期日期。 [我正在从数据库中读取域名] 示例:http://www.digicert.com/help/
我需要创建一个网络服务来检查到期日期。我该如何实施? - 我查看了很多不同的东西,例如 RequestCertificateValidationCallback 和 ClientCertificates 等。由于我是新手,我不确定要做什么。
我可能完全错了(因此我需要帮助),但我会创建一个 HTTPWebRequest,然后以某种方式请求客户端证书和特定元素吗?
我尝试了提供 @SSL 证书预取 .NET 的示例,但我遇到了被禁止的 403 错误。
任何帮助将不胜感激 - 谢谢。
这是我编写的抛出 403 禁止错误的代码。
Uri u = new Uri("http://services.efi.com/");
ServicePoint sp = ServicePointManager.FindServicePoint(u);
string groupName = Guid.NewGuid().ToString();
HttpWebRequest req = HttpWebRequest.Create(u) as HttpWebRequest;
req.Accept = "*/*";
req.ConnectionGroupName = groupName;
using (WebResponse resp = req.GetResponse())
{
// Ignore response, and close the response.
}
sp.CloseConnectionGroup(groupName);
// Implement favourite null check pattern here on sp.Certificate
string expiryDate = sp.Certificate.GetExpirationDateString();
string str = expiryDate;
【问题讨论】:
标签: c# ssl-certificate