checkcert.pl
· 932 B · Perl
Raw
#! /usr/bin/perl
#
# uses certexp.go from https://thrig.me/src/scripts.git/
#
# check certs of the form
#
# www.lehmann.cx:443
# irc.libera.chat:6697
# xmpp.hmm.st:5223
#
# only direct TLS connects work, STARTTLS does not
#
# typically you would put the program into a cronjob that runs once a day
#
# perl checkcert.pl domains.txt
#
#
# by alexlehm/at/gmail.com
#
use strict;
# warn time is 15 days before expiry
my @time=localtime(time()+15*24*60*60);
my $warntime=sprintf "%04d-%02d-%02d", $time[5]+1900, $time[4]+1, $time[3];
while(<>) {
chop;
next if /^#/;
my $host=$_;
open(PIPE, "~/certexp/certexp $host|");
my $notafter="";
while(<PIPE>) {
chop;
if(/^notAfter (.*)/) {
if($notafter eq "" | $1 le $notafter) {
$notafter=$1;
}
}
}
close PIPE;
if($notafter le $warntime) {
print "$host $notafter\n";
}
}
1 | #! /usr/bin/perl |
2 | |
3 | # |
4 | # uses certexp.go from https://thrig.me/src/scripts.git/ |
5 | # |
6 | |
7 | # check certs of the form |
8 | # |
9 | # www.lehmann.cx:443 |
10 | # irc.libera.chat:6697 |
11 | # xmpp.hmm.st:5223 |
12 | # |
13 | # only direct TLS connects work, STARTTLS does not |
14 | # |
15 | # typically you would put the program into a cronjob that runs once a day |
16 | # |
17 | # perl checkcert.pl domains.txt |
18 | # |
19 | |
20 | # |
21 | # by alexlehm/at/gmail.com |
22 | # |
23 | |
24 | use strict; |
25 | |
26 | # warn time is 15 days before expiry |
27 | my @time=localtime(time()+15*24*60*60); |
28 | |
29 | my $warntime=sprintf "%04d-%02d-%02d", $time[5]+1900, $time[4]+1, $time[3]; |
30 | |
31 | while(<>) { |
32 | chop; |
33 | |
34 | next if /^#/; |
35 | |
36 | my $host=$_; |
37 | |
38 | open(PIPE, "~/certexp/certexp $host|"); |
39 | my $notafter=""; |
40 | |
41 | while(<PIPE>) { |
42 | chop; |
43 | if(/^notAfter (.*)/) { |
44 | if($notafter eq "" | $1 le $notafter) { |
45 | $notafter=$1; |
46 | } |
47 | } |
48 | } |
49 | close PIPE; |
50 | if($notafter le $warntime) { |
51 | print "$host $notafter\n"; |
52 | } |
53 | } |
54 |
domains.txt
· 176 B · Text
Raw
ti-l.de:443
vps.lehmann.cx:443
www.lehmann.cx:443
gemini.lehmann.cx:443
gemini.lehmann.cx:1965
gemini.lehmann.cx:11965
womhole.axs.de:993
womhole.axs.de:995
womhole.axs.de:465
1 | ti-l.de:443 |
2 | vps.lehmann.cx:443 |
3 | www.lehmann.cx:443 |
4 | gemini.lehmann.cx:443 |
5 | gemini.lehmann.cx:1965 |
6 | gemini.lehmann.cx:11965 |
7 | womhole.axs.de:993 |
8 | womhole.axs.de:995 |
9 | womhole.axs.de:465 |
10 |