Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Check for an S/MIME Signing Time
See more MIME Examples
Demonstrates the Chilkat Mime.HasSignatureSigningTime method, which returns whether the signer at a zero-based index included a CMS signingTime signed attribute. The only argument is the signer index; use NumSignerCerts for the count.
Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.
Background: A signing time records when the signer claims to have signed, which matters for auditing and for validating a certificate that has since expired. It is an optional signed attribute, so not every signature has one — this predicate lets you check before calling
GetSignatureSigningTimeStr, avoiding an error for signers that omitted it. Being a signed attribute, it is covered by the signature and cannot be altered undetected.Chilkat Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.Mime;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
mime: TMime;
n: Integer;
i: Integer;
begin
success := False;
mime := TMime.Create;
success := mime.LoadMimeFile('qa_data/signed.eml');
if (success = False) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
// After verifying, check whether each signer included a CMS signingTime signed attribute. The
// only argument is the zero-based signer index.
success := mime.Verify();
if (success <> True) then
begin
WriteLn(mime.LastErrorText);
Exit;
end;
n := mime.NumSignerCerts;
for i := 0 to n - 1 do
begin
if (mime.HasSignatureSigningTime(i)) then
begin
WriteLn('Signer ' + i + ' included a signing time.');
end
else
begin
WriteLn('Signer ' + i + ' did not include a signing time.');
end;
end;
mime.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.