Last change
on this file since 2378 was
1847,
checked in by adehnert, 13 years ago
|
Merge changes from master
|
-
Property svn:executable set to
*
|
File size:
758 bytes
|
Rev | Line | |
---|
[1569] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use File::Basename; |
---|
| 5 | use Date::Parse; |
---|
[1571] | 6 | use Sys::Hostname; |
---|
[1569] | 7 | |
---|
[1572] | 8 | my @servers = qw(localhost); |
---|
[1569] | 9 | |
---|
[1571] | 10 | my $hostname = hostname(); |
---|
| 11 | |
---|
[1569] | 12 | my $now = time(); |
---|
| 13 | |
---|
| 14 | my $dir = dirname($0); |
---|
| 15 | |
---|
| 16 | our $verbose = 0; |
---|
| 17 | $verbose = 1 if ($ARGV[0] eq "-v"); |
---|
| 18 | |
---|
| 19 | use constant WARNING => 60*60*24*14; # Warn if a cert is expiring within 14 days |
---|
| 20 | |
---|
| 21 | foreach my $server (@servers) { |
---|
| 22 | open(X509, "-|", "$dir/ssl-get-endtime", "$server:636") or die "Couldn't invoke ssl-get-endtime: $!"; |
---|
| 23 | chomp(my $exp = <X509>); |
---|
| 24 | close(X509); |
---|
| 25 | $exp =~ s/^notAfter=// or warn "Cert appears broken: $server"; |
---|
| 26 | |
---|
| 27 | my $time = str2time($exp); |
---|
| 28 | |
---|
| 29 | if ($verbose || ($time - $now) <= WARNING) { |
---|
[1571] | 30 | printf "$hostname: Certificate expiring in %.2f days: %s\n", (($time - $now) / (60.0*60*24)), $server; |
---|
[1569] | 31 | } |
---|
| 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.