root/trunk/plagger/assets/plugins/CustomFeed-Script/ssl-expire.pl

Revision 1796 (checked in by miyagawa, 2 years ago)

add ssl-expire CustomFeed? script

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use YAML;
5
6 my @hosts = @ARGV
7     or die "Usage: ssl-expire.pl host1 host2 ...\n";
8
9 my $output = {
10     title => "SSL expire dates",
11     entry => [],
12 };
13
14 for my $host (@hosts) {
15     my $expires = expire_date($host);
16     push @{$output->{entry}}, {
17         title => $host,
18         date  => $expires,
19     };
20 }
21
22 sub expire_date {
23     my $host = shift;
24
25     my $res = `echo '' | openssl s_client -connect $host:443 2>/dev/null | openssl x509 -enddate -noout`;
26     if ($res =~ /notAfter=(.*)/) {
27         return $1;
28     }
29 }
30
31 print YAML::Dump $output;
32
Note: See TracBrowser for help on using the browser.