Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get Certificate Public Key from PEM
See more Certificates Examples
Demonstrates how to load a PEM file containing a certificate and access the public key.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,
Chilkat.PublicKey;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
cert: TCert;
pubkey: TPublicKey;
begin
success := False;
cert := TCert.Create;
success := cert.LoadFromFile('qa_data/pem/my_cert.pem');
if (success = False) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
pubkey := TPublicKey.Create;
cert.GetPublicKey(pubkey);
// Examine the public key as XML..
WriteLn(pubkey.GetXml());
cert.Free;
pubkey.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.