Sample code for 30+ languages & platforms
Pascal (Lazarus/Delphi)

Get Issuer Certificate Information

See more Certificates Examples

A certificate contains information about its issuer. This example demonstrates how to get the issuer information from a certificate.

Chilkat Pascal (Lazarus/Delphi) Downloads

Pascal (Lazarus/Delphi)
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;

  success := cert.LoadFromFile('qa_data/certs/sample.cer');
  if (success = False) then
    begin
      WriteLn(cert.LastErrorText);
      Exit;
    end;

  //  Get issuer information:

  //  -----------------------------------------------------------------------
  //  (Not all subject fields may exist depending on the issuer certificate.)
  //  -----------------------------------------------------------------------

  //  Issuer DN (Distinguished Name, i.e. all the Issuer subject parts)
  WriteLn('DN: ' + cert.IssuerDN);

  //  Common Subject parts:
  //  Issuer Common Name
  WriteLn('CN: ' + cert.IssuerCN);

  //  Issuer Country
  WriteLn('C: ' + cert.IssuerC);

  //  Issuer Email address
  WriteLn('E: ' + cert.IssuerE);

  //  Issuer Locality
  WriteLn('L: ' + cert.IssuerL);

  //  Issuer Organization
  WriteLn('O: ' + cert.IssuerO);

  //  Issuer Organizational Unit
  WriteLn('OU: ' + cert.IssuerOU);

  //  Issuer State
  WriteLn('S: ' + cert.IssuerS);


  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.