获取SSL证书信息 - .NET [英] obtain ssl certificate information - .net

查看:163
本文介绍了获取SSL证书信息 - .NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待从任何给定的域名的SSL证书获取数据。例如,我希望把任何网站地址例如 http://stackoverflow.com 和我的代码将首先检查是否SSL证书存在。如果是的话那么我想它拉出证书的失效日期。示例[我从DB读DOMAINNAMES]: http://www.digicert.com/help/



我需要创建一个Web服务来检查失效日期。我怎么才能实现它? - 我已经看过了不同的东西,如RequestCertificateValidationCallback和ClientCertificates等。由于我是新来这个,我不知道什么必须做负载



我可以是完全错误的(所以为什么我需要帮助),但我想创建一个HttpWebRequest和然后以某种方式要求客户端证书和具体内容呀?



我试过的例子提供@ 。SSL证书预取.NET,但我正在逐渐forbitten 403错误



任何帮助将非常感激 - 谢谢



这是代码我写它抛出403禁止错误。

 乌里U =新的URI( http://services.efi.com/); 
的ServicePoint SP = ServicePointManager.FindServicePoint(U);

串组名= Guid.NewGuid()的ToString();
HttpWebRequest的REQ = HttpWebRequest.Create(U)为HttpWebRequest的;
req.Accept =* / *;
req.ConnectionGroupName =组名;

使用(WebResponse类RESP = req.GetResponse())
{
//忽略响应,并关闭响应。
}
sp.CloseConnectionGroup(组名);

//这里实现零最爱检查图案上sp.Certificate
串expiryDate = sp.Certificate.GetExpirationDateString();

字符串str = expiryDate;


解决方案

您已经看到了403禁止的状态,因为这是什么,当你访问该页面的服务器返回。我看到了同样的事情,当我使用IE浏览器浏览到该URI。此状态表明您没有权限访问该网址,因此,或许你应该试试你的,你可以访问一个页面上的代码。



此外,你'重新不​​太可能看到在 HTTP 连接的证书 - 你可能想尝试 HTTPS 而不是

$。 b $ b

i am looking to get the data from any given domain names SSL certificate. For example I want to put in any website address e.g. "http://stackoverflow.com" and my code would firstly check if an SSL certificate exists. If it does then I want it to pull out the expiry date of the certificate. [ i am reading Domainnames from DB ] Example :http://www.digicert.com/help/

i need to create a web service to check expiry date. how can i implement it?? - I have looked up loads of different things such as RequestCertificateValidationCallback and ClientCertificates etc. Since i am new to this, i am not sure what has to be done.

I could be completely wrong (hence why I need help) but would I create a HTTPWebRequest and then somehow request the client certificate and specific elements that way?

i tried the example provided @SSL certificate pre-fetch .NET , but i am getting forbitten 403 error.

Any help would be much appreciated - Thank you.

This is the code i have written which is throwing 403 forbidden error.

        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;

解决方案

You are getting a "403 forbidden" status because that's what the server returns when you access that page. I see the same thing when I browse to that Uri using IE. This status indicates that you don't have permission to access the Url, so perhaps you should try your code on a page that you have access to.

Also, you're unlikely to see a certificate on a http connection - you might want to try https instead.

这篇关于获取SSL证书信息 - .NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆