Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Load Certificate from Smartcard in Reader (or from USB Token)
See more Certificates Examples
Demonstrates how to load the certificate that is on the smartcard currently inserted into the smartcard reader. (Also can load the smartcard on a USB token.)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;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
cert: TCert;
begin
success := False;
cert := TCert.Create;
// If you know the smart card PIN, set it prior to loading from the smartcard/USB token.
cert.SmartCardPin := '12345678';
// Pass an empty string to allow Chilkat to discover the smart card or USB token automatically.
success := cert.LoadFromSmartcard('');
if (success = False) then
begin
WriteLn(cert.LastErrorText);
Exit;
end;
WriteLn('Cert loaded from smartcard: ' + cert.SubjectCN);
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.