#!/usr/bin/perl $openssl = '/usr/bin/openssl'; $crt_filename = $ARGV[0]; $index_filename = "./index.txt"; open(OPENSSL, "$openssl x509 -noout -serial -subject -enddate -in $crt_filename |") || die "Can't open $openssl: $!"; while() { chomp; ($key, $value) = split(/\s*=\s*/, $_, 2); $key = uc($key); if ($key eq "NOTAFTER") { ($mon,$day,$time,$year,$stuff) = split(/ +/, $value, 5); $time =~ s/://g; %Months = ( 'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '09', 'Nov' => '11', 'Dec' => '12' ); $value = sprintf(qq[%s%02d%02d${time}Z], substr($year,2,2), $Months{$mon}, $day); } #printf(qq[%s="%s"\n], $key, $value); $$key = $value; } close(OPENSSL); open(DB, ">> $index_filename") || die "Can't open $index_filename: $!"; print DB "V\t$NOTAFTER\t\t$SERIAL\tunknown\t$SUBJECT\n"; close(DB); print "Data Base Updated\n";