- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要以编程方式确定 IIS 机器上 SSL 证书的到期日期。理想情况下,我想在 C# 中执行此操作,但如果 VB 脚本也是唯一可接受的方法。
环境 => IIS 版本 6 和 7、.NET 2.0、Windows 2003 和 2008
谢谢
最佳答案
我不熟悉使用 VBS 和/或 WMI 进行此检查的方法,因为这可能是一个安全整体,因为它可能会暴露私钥。但是,有一种方法可以利用普通的 HTTPS 连接来获取有关证书的公共(public)信息。如果您使用 IE 连接到任何安全网站,您可以转到"file"菜单并查看“属性”,然后单击“证书”按钮。这显示了站点的公共(public)证书信息对话框。您可以使用 C# 以编程方式获取此信息。
基本上,您要做的就是在端口 443 上打开到服务器的 TCP 连接,然后接收 SSL 数据。此数据流中包含有关证书的公共(public)信息,您可以对其进行验证并从中提取所需的所有信息,包括到期日期。这是一些示例代码:
static void Main(string[] args) {
foreach (string servername in args) {
Console.WriteLine("\n\nFetching SSL cert for {0}\n", servername);
TcpClient client = new TcpClient(servername, 443);
SslStream sslStream = new SslStream(client.GetStream(), false, callback, null);
try {
sslStream.AuthenticateAsClient(servername);
} catch (AuthenticationException ex) {
Console.WriteLine("Exception: {0}", ex.Message);
if (ex.InnerException != null) {
Console.WriteLine("Inner exception: {0}", ex.InnerException.Message);
}
Console.WriteLine("Authentication failed - closing the connection.");
}
client.Close();
}
}
以及处理证书信息的回调代码:
static RemoteCertificateValidationCallback callback = delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors sslError) {
X509Certificate2 x509 = new X509Certificate2(cert);
// Print to console information contained in the certificate.
Console.WriteLine("Subject: {0}", x509.Subject);
Console.WriteLine("Issuer: {0}", x509.Issuer);
Console.WriteLine("Version: {0}", x509.Version);
Console.WriteLine("Valid Date: {0}", x509.NotBefore);
Console.WriteLine("Expiry Date: {0}", x509.NotAfter);
Console.WriteLine("Thumbprint: {0}", x509.Thumbprint);
Console.WriteLine("Serial Number: {0}", x509.SerialNumber);
Console.WriteLine("Friendly Name: {0}", x509.PublicKey.Oid.FriendlyName);
Console.WriteLine("Public Key Format: {0}", x509.PublicKey.EncodedKeyValue.Format(true));
Console.WriteLine("Raw Data Length: {0}", x509.RawData.Length);
if (sslError != SslPolicyErrors.None) {
Console.WriteLine("Certificate error: " + sslError);
}
return false;
};
很酷的是,从技术上讲,这种方法应该适用于任何网络服务器......我只在 IIS 6 和 7 上测试过。
关于.net - 确定 SSL 证书到期日期 IIS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/826175/
通过Dropbox oAuth2 API获取的访问 token 的生存期是多少? https://api.dropbox.com/1/oauth2/token之后的答案类似于 { "acces
在 Braintree 中,当我生成带有 $customerId 的客户端 token 时,将该客户端 token 保存到数据库并在以后重新使用它有多可靠? 我总是有一个用户对应一个 $custome
我是新手,正在尝试编写一个简单的登录应用程序。当我离开登录页面一段时间并输入用户名和密码时,它不会登录,而是会执行 session 过期行为。我检查了日志,发现每当我收到 INFO - Session
我想导航到刷新 token 过期时的登录 View 。我如何在Android中使用 OkHttp 处理这种情况。刷新 token 到期时,服务器以错误代码 403禁止的响应。有什么方法可以处理刷新 t
我想知道 Backbone 模型/ Controller 是否有一种标准方法来处理 session 结束。我正在使用 node.js 作为我的 webapp 的后端,现在我将 session 存储在内
我正在使用 https://www.paypal.com/cgi-bin/webscr 用于进行 PayPal 付款。当任何用户点击 PayNow 按钮时,它将导航到用户输入其凭据的 PayPal 页
我们最近注册了一个 iOS Enterprise 帐户用于内部应用分发。 搜索论坛发现两件事我想得到确认: 1- 企业分发证书有效期为 3 年。这是否意味着我们需要在此时使用新证书重新构建应用程序,否
我遇到了一个奇怪的场景。基本上在我正在做的每个网页上 session_start(); if(!isset($_SESSION['login'])) header("Location: log
有许多工具可用于监控通过 HTTPS 提供的服务的 SSL 过期,例如我们使用 https://github.com/prometheus/blackbox_exporter当 SSL 证书在内部和外
我正在使用 Vapor 4 开发一个 Web 应用程序。在请求之间一次将客户端制作的数据保存在服务器端几分钟会很有用。我想使用 session 来做到这一点。但是,我对如何在设定时间后自动销毁这些数据
我正在使用带有自定义身份验证的 firebase 9.x。根据文档, token 到期时间不能超过一小时。是否有一个我可以注册的监听器,当 token 过期时将调用它。 该文档还讨论了 token 的
正在关注 http://code.google.com/apis/gmail/oauth/protocol.html#imap我正在尝试为使用 OAuth 的 Gmail 实现 IMAP 客户端。 我
试图确定是否由对 Accounts.sendResetPasswordEmail() 的调用生成的 token 将永远过期。我在 accounts-password 上找不到任何进一步的文档。包超出了
编辑:我对这本书的当前状态不感兴趣。这是各种结账的历史记录。 实际上,整个问题可能格式错误,无法回答。但无论如何我得到了答案,这很好。我主要是在寻找WHEN -> THEN结构。 我有books可以检
根据我的理解,在使用 Drive Java API 时,建议构建一个 Drive 类的实例,然后存储它,以便其他线程可以共享它。如果持有对 Drive 实例的引用的进程是一个长时间运行的进程(即无限期
我读到的关于 cookie 的所有内容都说,将 cookie 的到期时间设置为零应该使其成为“ session ”cookie,浏览器将在退出时将其删除。 http://www.cookiecentr
我正在制作一个使用jwt来验证数据库调用的 Angular 应用程序。 就是当 token 在服务器上过期时,由于过期的 token 仍在本地存储中,因此应用程序开始提供空白页而不是数据。经过一些研究
我在grails应用程序中使用spring安全性。在其他浏览器上使用相同的用户名登录时,我需要使上一个 session 到期。并发 session 限制是否有帮助?这该怎么做? 最佳答案 I need
当我向手机发送推送通知时遇到了麻烦,它返回了以下错误: [X-SubscriptionStatus] => Expired [X-NotificationStatus] => Dropped [X-D
我需要创建一个用户登录/注销/ session 到期跟踪页面(ASP.Net)..很明显,当用户登录和注销时,我可以调用我的跟踪页面。如何检测 session 过期? 最佳答案 在有状态应用程序中,最
我是一名优秀的程序员,十分优秀!