TChilkatCertStore Delphi Reference

TChilkatCertStore

* This is a freeware class/component/library.

Represents a certificate store. The certificate store can be registry-based, file-based, or in-memory. Allows certificates to be added, removed, or retrieved.

Object Creation

var
obj: IChilkatCertStore;
...
begin
obj := CoChilkatCertStore.Create();

Properties

property LastErrorHtml: WideString readonly

Error information in HTML format for the last method called.

property LastErrorText: WideString readonly

Error information in plain-text format for the last method called.

property LastErrorXml: WideString readonly

Error information in XML format for the last method called.

property LinkForSigning: Integer

If 1 then the certificates returned by the various FindCert* methods are linked internally with the corresponding private key (if it exists) before being returned. This property must be set to 1 if the returned digital certificate is to be used for creating a digital signature. The default value of this property is 0.

property NumCertificates: Integer readonly

The number of certificates held in the certificate store.

property NumEmailCerts: Integer readonly

The number of certificates that can be used for sending secure email within this store.

property Version: WideString readonly

The version of this component, such as "1.0"

Methods

procedure AddCertificate(cert: TChilkatCert);

Adds a certificate to the store. If the certificate is already in the store, it is updated with the new information.

function CreateFileStore(filename: WideString): Integer;

Creates a new file-based certificate store. Certificates may be saved to this store by calling AddCertificate.

Returns 1 for success, 0 for failure.

function CreateMemoryStore(): Integer;

Creates an in-memory certificate store. Certificates may be added by calling AddCertificate.

Returns 1 for success, 0 for failure.

function CreateRegistryStore(regRoot: WideString, regPath: WideString): Integer;

Creates a registry-based certificate store. regRoot must be "CurrentUser" or "LocalMachine". regPath is a registry path such as "Software/MyApplication/Certificates".

Returns 1 for success, 0 for failure.

function FindCertByRfc822Name(name: WideString): TChilkatCert;

Locates a certificate by its RFC 822 name and returns it if found. Otherwise returns NULL.

function FindCertBySerial(serialNumber: WideString): TChilkatCert;

Finds and returns the certificate that has the matching serial number.

function FindCertBySha1Thumbprint(str: WideString): TChilkatCert;

Finds a certificate by it's SHA-1 thumbprint. The thumbprint is a hexidecimal string.

function FindCertBySubject(str: WideString): TChilkatCert;

Finds a certificate where one of the Subject properties (SubjectCN, SubjectE, SubjectO, SubjectOU, SubjectL, SubjectST, SubjectC) matches exactly (but case insensitive) with the passed string. A match in SubjectCN will be tried first, followed by SubjectE, and SubjectO. After that, the first match found in SubjectOU, SubjectL, SubjectST, or SubjectC, but in no guaranteed order, is returned. All matches are case insensitive.

function FindCertBySubjectCN(commonName: WideString): TChilkatCert;

Finds a certificate where the SubjectCN property (common name) matches exactly (but case insensitive) with the passed string.

function FindCertBySubjectE(emailAddress: WideString): TChilkatCert;

Finds a certificate where the SubjectE property (email address) matches exactly (but case insensitive) with the passed string. This function differs from FindCertForEmail in that the certificate does not need to match the ForSecureEmail property.

function FindCertBySubjectO(organization: WideString): TChilkatCert;

Finds a certificate where the SubjectO property (organization) matches exactly (but case insensitive) with the passed string.

function FindCertForEmail(emailAddress: WideString): TChilkatCert;

Finds a certificate that can be used to send secure email to the passed email address. A certificate matches only if the ForSecureEmail property is TRUE, and the email address matches exactly (but case insensitive) with the SubjectE property. Returns NULL if no matches are found.

function GetCertificate(index: Integer): TChilkatCert;

Returns the Nth certificate in the store. The first certificate is at index 0.

function GetEmailCert(index: Integer): TChilkatCert;

Returns the Nth email certificate in the store. The first certificate is at index 0. Use the NumEmailCertificates property to get the number of email certificates.

function LoadPfxData(pfxData: OleVariant, password: WideString): Integer;

Loads a PFX from an in-memory image of a PFX file.

Returns 1 for success, 0 for failure.

function LoadPfxFile(pfxFilename: WideString, password: WideString): Integer;

Loads a PFX file.

Returns 1 for success, 0 for failure.

function OpenChilkatStore(readOnly: Integer): Integer;

Opens the registry-based local machine certificate store having the path "Software/Chilkat/SystemCertificates". If the certificate store does not exist, it is automatically created. Set readOnly = 1 if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = 1 will prevent many "permission denied" errors.

Returns 1 for success, 0 for failure.

function OpenCurrentUserStore(readOnly: Integer): Integer;

Opens the registry-based current-user certificate store. Set readOnly = 1 if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = 1 will prevent many "permission denied" errors.

Returns 1 for success, 0 for failure.

function OpenFileStore(filename: WideString, readOnly: Integer): Integer;

Opens a file-based certificate store.

Returns 1 for success, 0 for failure.

function OpenLocalSystemStore(readOnly: Integer): Integer;

Opens the registry-based local machine certificate store. Set readOnly = 1 if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = 1 will prevent many "permission denied" errors.

Returns 1 for success, 0 for failure.

function OpenOutlookStore(readOnly: Integer): Integer;

Opens the registry-based certificate store used by Outlook. Set readOnly = 1 if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = 1 will prevent many "permission denied" errors.

Returns 1 for success, 0 for failure.

function OpenRegistryStore(regRoot: WideString, regPath: WideString, readOnly: Integer): Integer;

Opens an arbitrary registry-based certificate store. regRoot must be "CurrentUser" or "LocalMachine". regPath is a registry path such as "Software/MyApplication/Certificates".

Returns 1 for success, 0 for failure.

procedure RemoveCertificate(cert: TChilkatCert);

Removes the passed certificate from the store. The certificate object passed as the argument can no longer be used once removed.

procedure SaveLastError(filename: WideString);

Saves the last error information to an XML formatted file.