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:
- 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.
- See also: ActiveX Registration Tutorial
- 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:
- In the Delphi RAD Studio, select the menu item "Component" --> "Import a Type Library".
- 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.
- Check the "Generate Component Wrappers" checkbox.
- Select a directory where the unit files (.pas and .dcr) should be generated.
- Select "Create Unit" and then "Finish".
- 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
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.
LastBinaryResult
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.
LastErrorHtml
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.
topLastErrorText
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.
LastErrorXml
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.
topLastMethodSuccess
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.
LastStringResult
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.
LastStringResultLen
The length, in characters, of the string contained in the LastStringResult property.
topNumCerts
The number of certificates contained within this object.
This is the number of certificates explicitly added by the methods AddCert, AddJavaKeyStore, and LoadCaCertsPem.
topRejectSelfSignedCerts
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).
topTrustSystemCaRoots
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.
VerboseLogging
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.
Version
Methods
Activate
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.
AddCert
AddJavaKeyStore
Adds the trusted certificates from a Java key store to the collection of trusted roots.
Returns 1 for success, 0 for failure.
AddJavaKeyStoreAsync (1)
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
CertAt
Returns in cert the Nth cert contained within this object. The 1st certificate is at index 0.
Returns 1 for success, 0 for failure.
topDeactivate
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.
topLoadCaCertsPem
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.
LoadCaCertsPemAsync (1)
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
LoadTaskCaller
Events
AbortCheck
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.
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; // ...
PercentDone
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.
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; // ...
ProgressInfo
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.
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; // ...
TaskCompleted
Called from the background thread when an asynchronous task completes.
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; // ...
Deprecated
GetCert
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