Lazarus Pascal Requires Chilkat v11.0.0+
Lazarus Pascal
Get Certificate's Public Key
Loads a certificate from PEM and gets the public key.Chilkat Lazarus Pascal 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;
strPem: string;
pubKey: TPublicKey;
begin
success := False;
cert := TCert.Create;
strPem := '-----BEGIN CERTIFICATE----- ...';
success := cert.LoadPem(strPem);
if (success = False) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
pubKey := TPublicKey.Create;
cert.GetPublicKey(pubKey);
// You can now use the public key object however it is needed,
// and access its various properties and methods..
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.