Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Get Public Key from Certificate PEM
See more Certificates Examples
Loads a certificate from a PEM file and gets the cert's 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/certs/someCert.pem');
if (success = False) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
// Get the certificate's public key:
pubkey := TPublicKey.Create;
cert.GetPublicKey(pubkey);
WriteLn(pubkey.GetPem(False));
// OK.. we have the public key which can be used in other Chilkat classes/methods...
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.