Sample code for 30+ languages & platforms
Perl

Verify the Timestamp Server Token (if any) while Validating a CMS Signature

Demonstrates how to also validate the timestamp server token (if any) while validating a CMS signature.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $crypt = Chilkat2::Crypt2->new;

# Tell Chilkat to also validate the timestamp token if a timestamp exists in the CMS message's unauthenticated attributes.
my $cmsOptions = Chilkat2::JsonObject->new;
$cmsOptions->UpdateBool('ValidateTimestampTokens', 1);
$crypt->CmsOptions($cmsOptions->Emit());

my $outputFile = 'qa_output/original.xml';
my $inFile = 'qa_data/p7m/fattura_signature.xml.p7m';

# Verify the signature and extract the contained file, which in this case is XML.
my $success = $crypt->VerifyP7M($inFile, $outputFile);
if (!$success) {
    print $crypt->LastErrorText, "\n";
    exit;
}

print "Signature validated.\n";