TrustedRoots Delphi ActiveX Reference Documentation

TChilkatTrustedRoots

Current Version: 11.1.0

Used to set and manage the CA root certificates trusted by your application. This applies to PKCS7 (S/MIME) signature validation and SSL/TLS server certificates.

Importing the Chilkat ActiveX into Delphi

Important: When upgrading to a new version of Chilkat, make sure to re-imported ActiveX DLL into Delphi to regenerate the files described below.


Chilkat v9.5.*: If using Chilkat v9.5.*, then use "Chilkat_v9_5_0_TLB" instead of "Chilkat_TLB", and the DLLs are named ChilkatAx-9.5.0-win32.dll (or ChilkatAx-9.5.0-x64.dll).


Two things are required to use an ActiveX in Delphi:

  1. The ActiveX DLL needs to be registered via regsvr32 on the system where the Delphi application runs. See How To Register ActiveX DLLs for detailed information.
  2. See also: ActiveX Registration Tutorial
  3. The ActiveX component needs to be "imported". Use the Delphi Import Component Wizard to import the Chilkat type library. This creates the following files: Chilkat_TLB.pas and Chilkat_TLB.dcr. The Chilkat_TLB.pas should be added to your project.

To import the Chilkat type library, do the following:

  1. In the Delphi RAD Studio, select the menu item "Component" --> "Import a Type Library".
  2. Find "Chilkat ActiveX" in the list and select it. This will only appear in the list if the ChilkatAx-win32.dll (or ChilkatAx-x64.dll) has been registered w/ regsvr32.
  3. Check the "Generate Component Wrappers" checkbox.
  4. Select a directory where the unit files (.pas and .dcr) should be generated.
  5. Select "Create Unit" and then "Finish".
  6. Add the .pas to your Delphi project.

To use a Chilkat ActiveX object in your Delphi code, add "Chilkat_TLB" to the "uses" statement. For example:

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

Object Creation

var
obj: TChilkatTrustedRoots;
...
begin
obj := TChilkatTrustedRoots.Create(Self);
...
// When finished, free the object instance.
obj.Free();

Properties

DebugLogFilePath
property DebugLogFilePath: WideString

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
LastBinaryResult
property LastBinaryResult: OleVariant readonly

This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to 1. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.

top
LastErrorHtml
property LastErrorHtml: WideString readonly

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
property LastErrorText: WideString readonly

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
property LastErrorXml: WideString readonly

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastMethodSuccess
property LastMethodSuccess: Integer

Indicates the success or failure of the most recent method call: 1 means success, 0 means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages.

top
LastStringResult
property LastStringResult: WideString readonly

In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.

top
LastStringResultLen
property LastStringResultLen: Integer readonly

The length, in characters, of the string contained in the LastStringResult property.

top
NumCerts
property NumCerts: Integer readonly
Introduced in version 9.5.0.38

The number of certificates contained within this object.

This is the number of certificates explicitly added by the methods AddCert, AddJavaKeyStore, and LoadCaCertsPem.

top
RejectSelfSignedCerts
property RejectSelfSignedCerts: Integer
Introduced in version 9.5.0.80

Indicates whether all self-signed certificates are to be rejected in SSL/TLS connections. The default value of this property is 0.

Note: This is for the case where the server certificate chain of authentication is 1 certificate long (i.e. the TLS server certificate itself is self-signed).

top
TrustSystemCaRoots
property TrustSystemCaRoots: Integer
Introduced in version 9.5.0.41

Indicates whether the operating system's CA root certificates are automatically trusted.

On a Windows operating system, this would be the registry-based CA certificate stores. On a Linux system, this could be /etc/ssl/certs/ca-certificates.crt, if it exists. The default value is 1. Set this property equal to 0 to prevent Chilkat from automatically trusting system-provided root CA certificates.

More Information and Examples
top
VerboseLogging
property VerboseLogging: Integer

If set to 1, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is 0. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
property Version: WideString readonly

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

Activate
function Activate(): Integer;
Introduced in version 9.5.0.38

Activates this collection of trusted roots as the set of CA and self-signed root certificates that are to be trusted Chilkat-wide for PKCS7 signature validation and SSL/TLS server certificate validation.

More Information and Examples
top
AddCert
function AddCert(cert: TChilkatCert): Integer;
Introduced in version 9.5.0.41

Adds a certificate to the collection of trusted roots.

top
AddJavaKeyStore
function AddJavaKeyStore(keystore: TChilkatJavaKeyStore): Integer;
Introduced in version 9.5.0.44

Adds the trusted certificates from a Java key store to the collection of trusted roots.

Returns 1 for success, 0 for failure.

top
AddJavaKeyStoreAsync (1)
function AddJavaKeyStoreAsync(keystore: TChilkatJavaKeyStore): TChilkatTask;
Introduced in version 9.5.0.44

Creates an asynchronous task to call the AddJavaKeyStore method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
CertAt
function CertAt(index: Integer; cert: TChilkatCert): Integer;
Introduced in version 11.0.0

Returns in cert the Nth cert contained within this object. The 1st certificate is at index 0.

Returns 1 for success, 0 for failure.

top
Deactivate
function Deactivate(): Integer;
Introduced in version 9.5.0.40

Deactivates a previous set of activated trusted roots so that all roots / self-signed certificates are implicitly trusted.

Returns 1 for success, 0 for failure.

top
LoadCaCertsPem
function LoadCaCertsPem(path: WideString): Integer;
Introduced in version 9.5.0.38

Loads a CA bundle in PEM format. This is a file containing CA root certificates that are to be trusted. An example of one such file is the CA certs from mozilla.org exported to a cacert.pem file by the mk-ca-bundle tool located here: http://curl.haxx.se/docs/caextract.html.

Note: This can also be called to load the /etc/ssl/certs/ca-certificates.crt file on Linux systems.

More Information and Examples
top
LoadCaCertsPemAsync (1)
function LoadCaCertsPemAsync(path: WideString): TChilkatTask;
Introduced in version 9.5.0.38

Creates an asynchronous task to call the LoadCaCertsPem method with the arguments provided.

Note: Async method event callbacks happen in the background thread. Accessing and updating UI elements existing in the main thread may require special considerations.

Returns nil on failure

top
LoadTaskCaller
function LoadTaskCaller(task: TChilkatTask): Integer;
Introduced in version 9.5.0.80

Loads the caller of the task's async method.

Returns 1 for success, 0 for failure.

top

Events

AbortCheck
procedure AbortCheck(ASender: TObject; out abort: Integer);

Enables a method call to be aborted by triggering the AbortCheck event at intervals defined by the HeartbeatMs property. If HeartbeatMs is set to its default value of 0, no events will occur. For instance, set HeartbeatMs to 200 to trigger 5 AbortCheck events per second.

More Information and Examples

Delphi ActiveX Event callback implementation:

procedure TForm1.trustedrootsAbortCheck(ASender: TObject;  out abort: Integer);
begin
    // Application code goes here...
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  trustedroots: TChilkatTrustedRoots;

begin
  trustedroots := TChilkatTrustedRoots.Create(Self);
  trustedroots.OnAbortCheck := trustedrootsAbortCheck;
  // ...
top
PercentDone
procedure PercentDone(ASender: TObject; pctDone: Integer; out abort: Integer);

This provides the percentage completion for any method involving network communications or time-consuming processing, assuming the progress can be measured as a percentage. This event is triggered only when it's possible and logical to express the operation's progress as a percentage. The pctDone argument will range from 1 to 100. For methods that finish quickly, the number of PercentDone callbacks may vary, but the final callback will have pctDone equal to 100. For longer operations, callbacks will not exceed one per percentage point (e.g., 1, 2, 3, ..., 98, 99, 100).

The PercentDone callback also acts as an AbortCheck event. For fast methods where PercentDone fires, an AbortCheck event may not trigger since the PercentDone callback already provides an opportunity to abort. For longer operations, where time between PercentDone callbacks is extended, AbortCheck callbacks enable more responsive operation termination.

To abort the operation, set the abort output argument to 1. This will cause the method to terminate and return a failure status or corresponding failure value.

More Information and Examples

Delphi ActiveX Event callback implementation:

procedure TForm1.trustedrootsPercentDone(ASender: TObject;  pctDone: Integer; out abort: Integer);
begin
    // Application code goes here...
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  trustedroots: TChilkatTrustedRoots;

begin
  trustedroots := TChilkatTrustedRoots.Create(Self);
  trustedroots.OnPercentDone := trustedrootsPercentDone;
  // ...
top
ProgressInfo
procedure ProgressInfo(ASender: TObject; const name: WideString; const value: WideString);

This event callback provides tag name/value pairs that detail what occurs during a method call. To discover existing tag names, create code to handle the event, emit the pairs, and review them. Most tag names are self-explanatory.

More Information and Examples

Delphi ActiveX Event callback implementation:

procedure TForm1.trustedrootsProgressInfo(ASender: TObject;  const name: WideString; const value: WideString);
begin
    // Application code goes here...
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  trustedroots: TChilkatTrustedRoots;

begin
  trustedroots := TChilkatTrustedRoots.Create(Self);
  trustedroots.OnProgressInfo := trustedrootsProgressInfo;
  // ...
top
TaskCompleted
procedure TaskCompleted(ASender: TObject; const task: IChilkatTask);

Called from the background thread when an asynchronous task completes.

More Information and Examples

Delphi ActiveX Event callback implementation:

procedure TForm1.trustedrootsTaskCompleted(ASender: TObject;  const task: IChilkatTask);
begin
    // Application code goes here...
end;


procedure TForm1.Button1Click(Sender: TObject);
var
  trustedroots: TChilkatTrustedRoots;

begin
  trustedroots := TChilkatTrustedRoots.Create(Self);
  trustedroots.OnTaskCompleted := trustedrootsTaskCompleted;
  // ...
top

Deprecated

GetCert
function GetCert(index: Integer): TChilkatCert;
Introduced in version 9.5.0.38
This method is deprecated and replaced by CertAt

This method is deprecated. Applications should instead call CertAt.

Returns the Nth cert contained within this object. The 1st certificate is at index 0.

Returns nil on failure

More Information and Examples
top