Skip to content

Commit 1703962

Browse files
committed
Merge remote-tracking branch 'remotes/origin/master' into ansible-realserver
2 parents 9487962 + dd28bbf commit 1703962

File tree

1 file changed

+11
-4
lines changed
  • ansible/roles/real-httpd/files/certs

1 file changed

+11
-4
lines changed

ansible/roles/real-httpd/files/certs/check.pl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use constant WARNING => 60*60*24*14; # Warn if a cert is expiring within 14 days
2020

21+
my @expired;
2122
foreach my $cert (glob("*.pem"), glob("/var/lib/scripts-certs/*.pem")) {
2223
open(CERT, "<", $cert);
2324
my $ins = do {local $/; <CERT>};
@@ -40,10 +41,16 @@
4041
my $time = str2time($exp);
4142

4243
if ($verbose || ($time - $now) <= WARNING) {
43-
printf "Certificate expiring in %.2f days: %s for ", (($time - $now) / (60.0*60*24)), $cert;
44-
open(IN, '|-', qw(openssl x509 -subject -noout));
45-
print IN $in;
46-
close(IN);
44+
push @expired, [$time - $now, $cert, $in];
4745
}
4846
}
4947
}
48+
49+
@expired = reverse sort {$a->[0] <=> $b->[0]} @expired;
50+
foreach my $expired_cert (@expired) {
51+
my ($age, $cert, $in) = @$expired_cert;
52+
printf "Certificate expiring in %.2f days: %s for ", ($age / (60.0*60*24)), $cert;
53+
open(IN, '|-', qw(openssl x509 -subject -noout));
54+
print IN $in;
55+
close(IN);
56+
}

0 commit comments

Comments
 (0)