Object Creation

Properties

DebugLogFilePath

If set to a file path, causes each Chilkat method or property call to automatically append it's LastErrorText to the specified log file. The information is appended such that if a hang or crash occurs, it is possible to see the context in which the problem occurred, as well as a history of all Chilkat calls up to the point of the problem. The VerboseLogging property can be set to provide more detailed information.

This property is typically used for debugging the rare cases where a Chilkat method call hangs or generates an exception that halts program execution (i.e. crashes).
A hang or crash should generally never happen. The typical causes of a hang are:

a timeout related property was set to 0 to explicitly indicate that an infinite timeout is desired,

the hang is actually a hang within an event callback (i.e. it is a hang within the application code), or

there is an internal problem (bug) in the Chilkat code that causes the hang.

LastErrorText

# strVal is a string
# ckStr is a CkStringpfx.get_LastErrorText(ckStr);
strVal = pfx.lastErrorText();

Provides information in plain-text format about the last method/property called. If a method call returns a value indicating failure, or behaves unexpectedly, examine this property to get more information.

LastMethodSuccess

Indicate whether the last method call succeeded or failed. A value of true indicates success, a value of false indicates failure. This property is automatically set for method calls. It is not modified by property accesses. The property is automatically set to indicate success for the following types of method calls:

Utf8

When set to true, all "const char *" arguments are interpreted as utf-8 strings. If set to false (the default), then "const char *" arguments are interpreted as ANSI strings.
Also, when set to true, and Chilkat method returning a "const char *" is returning the utf-8 representation. If set to false, all "const char *" return values are ANSI strings.

VerboseLogging

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

Methods

AddCert

Adds a certificate, its private key (if it exists), and potentially its certificate chain to the PFX. If includeChain is true, then the certificate must have a private key. The certificate's private key is automatically obtained (internally) via the cert's ExportPrivateKey method. If the certificate's chain of authentication is to be added, it is automatically constructed and added using whatever resources are at hand (such as certs provided via the UseCertVault method, the trusted roots from Chilkat's TrustedRoots class, etc. If a certificate chain is to be added, which is the typical case, then the chain must be completed to the root to succeed.

AddPrivateKey

Adds a private key and certificate chain to the PFX. The private key should be such that it is associated with the 1st certificate in the chain. In other words, the 1st certificate in the chain has a public key (embedded within the X.509 structure of the cert itself) that is the counterpart to the private key.

ToJavaKeyStore

Converts the PFX (PKCS12) to a JavaKeyStore object. One JKS entry per private key found in the PKCS12 is added. The certs found within the PCKS12 are used to build the certificate chains for each private key. (A typical PFX file contains a single private key along with its associated certificate, and the certificates in the chain of authentication to the root CA cert.)

The specified alias is applied to the 1st private key found. If the alias is empty, then the alias is obtained from the cert/PFX in the following order of preference:

Certificate's subject common name

Certificate's subject email address

Certificate's friendly name found in the PKCS9 attributes of the PKCS12

Certificate's serial number

If multiple private keys are found in the PKCS12, then all but the first will automaticallly be assigned aliases using the preference just described.

Write the PFX to a PEM formatted string. If extendedAttrs is true, then extended properties (Bag Attributes and Key Attributes) are output. If noKeys is true, then no private keys are output. If noCerts is true, then no certificates are output. If noCaCerts is true, then no CA certs or intermediate CA certs are output. If encryptAlg is not empty, it indicates the encryption algorithm to be used for encrypting the private keys (otherwise the private keys are output unencrypted). The possible choices for the encryptAlg are "des3", "aes128", "aes192", and "aes256". (All encryption algorithm choices use CBC mode.) If the private keys are to be encrypted, then password is the password to be used. Otherwise, password may be left empty.
For example: