Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Use a Certificate Vault for Chain Building
See more PFX/P12 Examples
Demonstrates Pfx.UseCertVault, which adds the certificates in an XmlCertVault to the set of sources available for later chain-building operations such as AddCert.
The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.
Background. The call captures a point-in-time snapshot of the vault's certificates. Providing extra intermediate certificates lets Chilkat complete certificate chains when building a PFX.
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.XmlCertVault,
Chilkat.Pfx;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
pfx: TPfx;
vault: TXmlCertVault;
begin
success := False;
pfx := TPfx.Create;
// The file path is relative to the application's current working directory. An absolute path
// may also be used. Supply the path appropriate to your own environment.
// Load additional certificates (such as intermediate CA certificates) into a certificate vault.
vault := TXmlCertVault.Create;
success := vault.AddCertFile('qa_data/intermediate_ca.cer');
if (success = False) then
begin
WriteLn(vault.LastErrorText);
Exit;
end;
// Make the vault's certificates available as sources for later chain-building operations, such as
// AddCert. The call captures a point-in-time snapshot of the vault's certificates.
success := pfx.UseCertVault(vault);
if (success = False) then
begin
WriteLn(pfx.LastErrorText);
Exit;
end;
WriteLn('Certificate vault registered as a chain-building source.');
pfx.Free;
vault.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.