source: branches/fc13-dev/locker/sbin/check-ldap-cert.pl @ 2622

Last change on this file since 2622 was 1572, checked in by adehnert, 15 years ago
Check localhost, not all the web hosts
  • Property svn:executable set to *
File size: 758 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use File::Basename;
5use Date::Parse;
6use Sys::Hostname;
7
8my @servers = qw(localhost);
9
10my $hostname = hostname();
11
12my $now = time();
13
14my $dir = dirname($0);
15
16our $verbose = 0;
17$verbose = 1 if ($ARGV[0] eq "-v");
18
19use constant WARNING => 60*60*24*14; # Warn if a cert is expiring within 14 days
20
21foreach 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) {
30    printf "$hostname: Certificate expiring in %.2f days: %s\n", (($time - $now) / (60.0*60*24)), $server;
31  }
32}
Note: See TracBrowser for help on using the repository browser.