您如何跟踪客户的托管/域名/SSL 证书到期日期?

发布于 2024-07-10 08:47:45 字数 1570 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

远昼 2024-07-17 08:47:45

我们把它变成一个编程问题怎么样? 您可以使用此代码(C#),但我建议对其进行一些修改(例如将 url 放入文件中)并将其放入服务中。

此代码设置一个证书验证回调,HttpWebRequest 将在遇到证书时调用该回调。 这让我们看一下证书,通常这用于验证证书,但我们将查看过期时间,如果在 3 个月内,我们将向自己发送一封电子邮件。 设置计时器每天运行一次检查。

using System.Net;
using System.Diagnostics;
using System.Net.Mail;
using System.Threading;

static void Main(string[] args)
{
    // List of URL's to check
    string[] urls = new string[]{
        "https://www.6bit.com/",
        "https://www.google.com/"
    };

    HttpWebRequest req = null;

    // Certificate check callback
    ServicePointManager.ServerCertificateValidationCallback = (state, cert, certChain, sslerr) =>
    {
        DateTime expiration = DateTime.Parse(cert.GetExpirationDateString());
        if (expiration < DateTime.Now.AddMonths(3))
        {
            Debug.WriteLine("Cert expiring on " + expiration.ToShortDateString());
            MailMessage msg = new MailMessage("[email protected]", "[email protected]", "SSL Certificate Expiring", "The ssl certificate for" + req.RequestUri.ToString() + " will expire on " + expiration.ToShortDateString());
            SmtpClient sc = new SmtpClient();
            sc.Send(msg);
        }

        return true;
    };

    // Request each url once a day so that the validation callback runs for each
    Timer t = new Timer(s =>
    {
        Array.ForEach(urls, url =>
        {
            try
            {
                req = (HttpWebRequest)HttpWebRequest.Create(url);
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                resp.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error checking site: " + ex.ToString());
            }
        });
    }, null, TimeSpan.FromSeconds(0), TimeSpan.FromDays(1));  // Run the timer now and schedule to run once a day
}

How about we turn it into a programming question! You could use this code (C#), though I would recommend modifying it a bit (e.g. put url's in a file) and throwing it into a service.

This code sets up a certificate validation callback which the HttpWebRequest will call anytime it encounters a certificate. This lets us take a look at the certificate, usually this is used to validate the cert but we are going to look at the expiration time and if it within 3 months we will send an email to ourselves. A timer is setup to run the check once a day.

using System.Net;
using System.Diagnostics;
using System.Net.Mail;
using System.Threading;

static void Main(string[] args)
{
    // List of URL's to check
    string[] urls = new string[]{
        "https://www.6bit.com/",
        "https://www.google.com/"
    };

    HttpWebRequest req = null;

    // Certificate check callback
    ServicePointManager.ServerCertificateValidationCallback = (state, cert, certChain, sslerr) =>
    {
        DateTime expiration = DateTime.Parse(cert.GetExpirationDateString());
        if (expiration < DateTime.Now.AddMonths(3))
        {
            Debug.WriteLine("Cert expiring on " + expiration.ToShortDateString());
            MailMessage msg = new MailMessage("[email protected]", "[email protected]", "SSL Certificate Expiring", "The ssl certificate for" + req.RequestUri.ToString() + " will expire on " + expiration.ToShortDateString());
            SmtpClient sc = new SmtpClient();
            sc.Send(msg);
        }

        return true;
    };

    // Request each url once a day so that the validation callback runs for each
    Timer t = new Timer(s =>
    {
        Array.ForEach(urls, url =>
        {
            try
            {
                req = (HttpWebRequest)HttpWebRequest.Create(url);
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                resp.Close();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error checking site: " + ex.ToString());
            }
        });
    }, null, TimeSpan.FromSeconds(0), TimeSpan.FromDays(1));  // Run the timer now and schedule to run once a day
}
送君千里 2024-07-17 08:47:45

使用通常用来管理时间/日程的任何工具可能比使用一些专门的工具更好。 无论是 Outlook、Sunbird、Lightning、PDA、手机、纸质日历等。只需使用您通常用来跟踪日期的任何工具即可。

[附加]

详细来说,您希望将其全部放在与其他重要日期相同的位置的原因是它可以确保(至少一点点)您关注该列表。 如果您使用其他类型的程序,很容易忙上几个星期,而忘记查看您的特殊工具,最终让一些不应该过期的东西过期。

You would probably be better off using whatever tool you usually use for managing your time/schedule than having some specialized tool. Be it Outlook, Sunbird, Lightning, a PDA, cell phone, paper calendar, etc. Just use whatever tool you normally use for keeping track of dates.

[ADDITION]

To elaborate, the reason you want it all in the same place as the rest of your important dates is that it ensures (at least a little) that you pay attention to the list. If you're using some other kind of program, it's too easy to get busy for a couple weeks, and forget to look at your special tool, and end up letting something expire that shouldn't expire.

梦明 2024-07-17 08:47:45

关于管理 SSL 证书,您可以编写一个调用 OpenSSL 的脚本,或者如果您想要准备一些东西,您可以尝试以下操作:

SSL 证书发现和监控工具

它将在您的网络上查找和编录证书,并在证书即将到期时发送电子邮件警报。 结果可以导入到名为“证书中心”的网络工具中。

With regards to managing SSL certs, you could write a script that calls OpenSSL or if you want something ready made you could try this:

SSL Certificate Discovery and Monitoring Tool

It will find and catalogue certificates on your networks and send email alerts when they are approaching expiry. The results can be imported into a web based tool called Cert Centre.

泼猴你往哪里跑 2024-07-17 08:47:45

尝试 epazote 基本上,您可以在 yaml 文件上创建站点(服务)列表并接收电子邮件/警报/证书过期前的 hipchat 通知,例如:

services:
    google:
        url: https://www.google.com
        seconds: 60
        expect:
            status: 302
            ssl:
                hours: 72

在这种情况下,可以在证书过期前 72 小时发送电子邮件。

更多详细信息请参见:https://epazote.io/post/how-to-use-它/

Give a try to epazote basically you can create a list of sites (services) on a yaml file and receive an email/alert/hipchat notification before the certificate expires, example:

services:
    google:
        url: https://www.google.com
        seconds: 60
        expect:
            status: 302
            ssl:
                hours: 72

In this case an email could be sent, 72 hours before the certificate expires.

More details here: https://epazote.io/post/how-to-use-it/

め七分饶幸 2024-07-17 08:47:45

您可以使用 https://IsItWorking.info 等服务来跟踪域注册和 SSL 证书到期情况。

您可以设置何时收到通知(例如到期前 60 天),它可以通过电子邮件、slack 或 Pushover 通知您。

(全面披露:我写的!)

You can use a service like https://IsItWorking.info to track domain registration, and SSL certificate expiry.

You can set when you want to get notifications (e.g. 60 days before expiry) and it can notify you by email, slack or pushover.

(full disclosure: I wrote it!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文