Re: Ablaufdatum von Zertifikaten pruefen?

Vorländer, Martin <[email protected]>
Newsgroups gmane.comp.otsr.user.german
Message-ID <[email protected]>
Moin!

Das angehängte, mal eben zusammengestoppelte Skript liest die Keys/Zertifikate aus und gibt evtl. eine Meldung aus.
Vielleicht kann es ja als Ausgangspunkt für etwas Nützliches dienen.

Disclaimer: Das Skript wurde unter OTRS4 geschrieben und getestet, sollte mit den angemerkte Änderungen aber auch unter OTRS5 funktionieren.

cu,
  Martin

Am Montag, 20. August 2018 17:16 schrieb Andrea Wardzichowski:
> Ich ergänz nochmal, das war missverständlich glaube ich:
> 
> Ich meine die Zertifikate zum Signieren von Mails.
> Die kann ich mir zwar prima listen lassen, aber :) Die der Webseiten haben wir ganz gut im Griff.
> 
> 
> LG,
> Andrea
> 
> 
> On Mon, Aug 20, 2018 at 04:08:12PM +0200, Andrea Wardzichowski wrote:
> > Liebe Gemeinde,
> > 
> > heut fiel mir wieder ein neues Thema auf den Fuß:
> > 
> > wir verwenden S/MIME-Zertifikate und einige davon waren abgelaufen.
> > 
> > Gibt es eine Möglichkeit, diese automatisiert zu überwachen, also 
> > Ablaufdatum auslesen und mailen? Jeden Monat 'reinsehen is irgendwie 
> > nicht so 2018 ;-)
> > 
> > Viele Grüße aus Stuttgart,
> > Andrea

---------------------------------------------------------------------
OTRS mailing list: otrs-de - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/otrs-de
To unsubscribe: http://lists.otrs.org/mailman/listinfo/otrs-de
CheckSMIME.pl.txt (text/plain, 1.3 KB)
#!/usr/bin/perl
use strict;
use warnings;

my $days = 30;

#use FindBin qw($Bin);
our $Bin; BEGIN { $Bin='/opt/otrs/bin'; }
use lib "$Bin/..";
use lib "$Bin/../Kernel/cpan-lib";
use lib "$Bin/../Custom";

use Kernel::System::ObjectManager;

# create object manager
local $Kernel::OM = Kernel::System::ObjectManager->new(
    'Kernel::System::Log' => {
        LogPrefix => 'OTRS-PDV.ShowSMIME.pl',
    },
);

my $TimeObject = $Kernel::OM->Get('Kernel::System::Time');
my $SystemTime = $TimeObject->CurrentTimestamp();
my $TimeStamp = $TimeObject->SystemTime2TimeStamp(
    SystemTime => $TimeObject->SystemTime() + $days*86400,
);

# für OTRS4
# ---
$Kernel::OM->ObjectParamAdd(
    'Kernel::System::Crypt' => { CryptType => 'SMIME' }
);
my $SMIMEObject  = $Kernel::OM->Get('Kernel::System::Crypt');
# ---

# für OTRS5
# ---
my $SMIMEObject  = $Kernel::OM->Get('Kernel::System::Crypt::SMIME');
# ---

my @List = ();
if ($SMIMEObject) {
    @List = $SMIMEObject->Search();
}

for my $Attributes (@List) {
    if ($Attributes->{ShortEndDate} lt $SystemTime) {
        print "$Attributes->{Type} $Attributes->{Subject} is expired\n";
    }
    elsif ($Attributes->{ShortEndDate} lt $TimeStamp) {
        print "$Attributes->{Type} $Attributes->{Subject} will expire in less than $days days\n";
    }
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.