Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Apple Keychain - List Certificates
See more Apple Keychain Examples
Iterates over the certificates in the Apple Keychain.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.CertStore;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
certStore: TCertStore;
numCerts: Integer;
cert: TCert;
i: Integer;
begin
success := False;
certStore := TCertStore.Create;
// On MacOS and iOS, the OpenCurrentUserStore method opens the Keychain.
// The argument passed to OpenCurrentUserStore is ignored.
success := certStore.OpenCurrentUserStore(False);
if (success = False) then
begin
WriteLn(certStore.LastErrorText);
Exit;
end;
numCerts := certStore.NumCertificates;
WriteLn('numCerts = ' + numCerts);
cert := TCert.Create;
i := 0;
while i < numCerts do
begin
certStore.GetCert(i,cert);
WriteLn(cert.SubjectDN);
WriteLn(cert.SubjectCN);
WriteLn(cert.SerialNumber);
WriteLn('----');
i := i + 1;
end;
certStore.CloseCertStore();
certStore.Free;
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.