Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Load PEM Format Certificate (.pem)
See more Certificates Examples
Loads a PEM format digital certificate and fetches information about the cert.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.Cert;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
cert: TCert;
begin
success := False;
cert := TCert.Create;
// LoadFromFile will load virtually any certificate format file.
// It will auto-recognize the format and load appropiately.
success := cert.LoadFromFile('/Users/chilkat/testData/cer/cert.pem');
if (success <> True) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
// DN = "Distinguished Name"
WriteLn('SubjectDN:' + cert.SubjectDN);
WriteLn('Common Name:' + cert.SubjectCN);
WriteLn('Issuer Common Name:' + cert.IssuerCN);
WriteLn('Serial Number:' + cert.SerialNumber);
cert.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.