#!/usr/bin/perl use Date::Calc qw(Delta_DHMS); @files = `find /home/conetadm/.TinyCA/ -name index.txt`; foreach $file (@files) { open FILE, "$file"; push @certs, ; close FILE; } foreach $cert (@certs) { next unless $cert =~ /^V/; chomp $cert; ($valid, $time, undef, $serial, $unknown, $oustr) = split /\t/, $cert; ($o, $ou, $cn, $email) = $oustr =~ /O=(.*)\/OU=(.*)\/CN=(.*)\/emailAddress=(.*)/; $cn =~ s/\\xE4/ä/g; $cn =~ s/\\xC4/Ä/g; $cn =~ s/\\xF6/ö/g; $cn =~ s/\\xD6/Ö/g; $cn =~ s/\\xFC/ü/g; $cn =~ s/\\xDC/Ü/g; $cn =~ s/\\xDF/ß/g; ($cyy, $cmo, $cdd, $chh, $cmm, $css) = $time =~ /([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/; $cyy+=2000; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year+=1900; $mon++; ($Dd,$Dh,$Dm,$Ds) = Delta_DHMS($year,$mon,$mday,$hour,$min,$sec, $cyy,$cmo,$cdd,$chh,$cmm,$css); if ($Dd < 30 && $Dd > -1) { print "Certificate ($cn) for $email expires in $Dd day(s)\n"; #`echo "" | mutt -H /tmp/mailfile.tmp -a $OUTFILE -- $MAIL`; `echo "Certificate (CN=$cn, O=$o, OU=$ou) for $email expires in $Dd days.\n" | mailx -a "From: CONET Services Certificate Authority " -a "Return-Path: help\@conet.de" -s "Certificate expiration warning" help\@conet.de`; #$email="ageissler\@conet.de"; $SUBJECT="Certificate expiration warning"; $CONTENT=" \n \nYour certificate ($cn $email) will expire in $Dd day(s).
\nReply to this email, please!
\n
\nIhr Zertifikat ($cn $email) wird in $Dd Tag(en) ablaufen.
\nBitte antworten Sie auf diese Mail!
\n
\nRenew certificate? / Zertifikat verlängern? [Ja/Nein]
\n
\n \n \n"; `(echo "Subject: $SUBJECT\nMIME-Version: 1.0\nFrom: help\@conet.de\nTo:$email\nContent-Type: text/html\nContent-Disposition: inline\n\n";echo "$CONTENT") | /usr/sbin/sendmail -f help\@conet.de $email`; } }