File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
ansible/roles/real-httpd/files/certs Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 18
18
19
19
use constant WARNING => 60*60*24*14; # Warn if a cert is expiring within 14 days
20
20
21
+ my @expired ;
21
22
foreach my $cert (glob (" *.pem" ), glob (" /var/lib/scripts-certs/*.pem" )) {
22
23
open (CERT, " <" , $cert );
23
24
my $ins = do {local $/ ; <CERT>};
40
41
my $time = str2time($exp );
41
42
42
43
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 ];
47
45
}
48
46
}
49
47
}
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
+ }
You can’t perform that action at this time.
0 commit comments