ChilkatCertStore ActiveX Reference
ChilkatCertStore
* This is a freeware class/component/library.
Represents a collection of certificates. The certificates may be loaded from a PFX (PKCS#12) or from a Windows-based certificate store. Many of the methods of this class are only applicable when running on a MS Windows operating system. The methods for opening, creating, and modifying Windows-based certificate stores (registry-based, file-based, and memory-based) are (of course) Windows-only. However, the methods for loading certs from PFX (PKCS#12), are valid on all supported operating systems, including Linux, MAC OS X, Windows, etc.
Object Creation
(Visual Basic 6.0)
Dim obj As New ChilkatCertStore
(ASP)
set obj = Server.CreateObject("Chilkat.CertStore")
(VBScript)
set obj = CreateObject("Chilkat.CertStore")
(Delphi)
obj := TChilkatCertStore.Create(Self);
(FoxPro)
loObject = CreateObject('Chilkat.CertStore')
(SQL Server)
EXEC @hr = sp_OACreate 'Chilkat.CertStore', @obj OUT
(Javascript)
var obj = new ActiveXObject("Chilkat.CertStore");
Properties
AvoidWindowsPkAccess As Long
Applies only when running on a Microsoft Windows operating system. If 1, then any method that returns a certificate will not try to also access the associated private key, assuming one exists. This is useful if the certificate was installed with high-security such that a private key access would trigger the Windows OS to display a security warning dialog. The default value of this property is 0.
LastErrorHtml As String (read-only)
Error information in HTML format for the last method called.
LastErrorText As String (read-only)
Error information in plain-text format for the last method called.
LastErrorXml As String (read-only)
Error information in XML format for the last method called.
LinkForSigning As Long
(Relevant only when running on a Microsoft Windows operating system.) 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.
NumCertificates As Long (read-only)
The number of certificates held in the certificate store.
NumEmailCerts As Long (read-only)
The number of certificates that can be used for sending secure email within this store.
VerboseLogging As Long
If set to 1, then the LastErrorText may contain more verbose logging.
Version As String (read-only)
The version of this component, such as "1.0"
Methods
AddCertificate(cert As ChilkatCert)
Adds a certificate to the store. If the certificate is already in the store, it is updated with the new information. Returns 1 for success, 0 for failure.
CreateFileStore(filename As String) As Long
(Relevant only when running on a Microsoft Windows operating system.) Creates a new file-based certificate store. Certificates may be saved to this store by calling AddCertificate. Returns 1 for success, 0 for failure.
CreateMemoryStore() As Long
(Relevant only when running on a Microsoft Windows operating system.) Creates an in-memory certificate store. Certificates may be added by calling AddCertificate. Returns 1 for success, 0 for failure.
CreateRegistryStore(regRoot As String, regPath As String) As Long
(Relevant only when running on a Microsoft Windows operating system.) 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.
FindCertByRfc822Name(name As String) As ChilkatCert
Locates a certificate by its RFC 822 name and returns it if found.
Returns Nothing on failure.
FindCertBySerial(serialNumber As String) As ChilkatCert
Finds and returns the certificate that has the matching serial number.
Returns Nothing on failure.
FindCertBySha1Thumbprint(str As String) As ChilkatCert
Finds a certificate by it's SHA-1 thumbprint. The thumbprint is a hexidecimal string.
Returns Nothing on failure.
FindCertBySubject(str As String) As ChilkatCert
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.
Returns Nothing on failure.
FindCertBySubjectCN(commonName As String) As ChilkatCert
Finds a certificate where the SubjectCN property (common name) matches exactly (but case insensitive) with the passed string
Returns Nothing on failure.
FindCertBySubjectE(emailAddress As String) As ChilkatCert
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.
Returns Nothing on failure.
FindCertBySubjectO(organization As String) As ChilkatCert
Finds a certificate where the SubjectO property (organization) matches exactly (but case insensitive) with the passed string.
Returns Nothing on failure.
FindCertForEmail(emailAddress As String) As ChilkatCert
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.
Returns Nothing on failure.
GetCertificate(index As Long) As ChilkatCert
Returns the Nth certificate in the store. The first certificate is at index 0.
Returns Nothing on failure.
GetEmailCert(index As Long) As ChilkatCert
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.
Returns Nothing on failure.
LoadPfxData(pfxData As Variant, password As String) As Long
Loads a PFX from an in-memory image of a PFX file. Once loaded, the certificates within the PFX may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate within the PFX. Returns 1 for success, 0 for failure.
LoadPfxFile(pfxFilename As String, password As String) As Long
Loads a PFX file. Once loaded, the certificates within the PFX may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate within the PFX. Returns 1 for success, 0 for failure.
OpenChilkatStore(readOnly As Long) As Long
(Relevant only when running on a Microsoft Windows operating system.) 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. Once loaded, the certificates within the store may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate contained in the store. Returns 1 for success, 0 for failure.
OpenCurrentUserStore(readOnly As Long) As Long
(Relevant only when running on a Microsoft Windows operating system.) 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. Once loaded, the certificates within the store may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate contained in the store. Returns 1 for success, 0 for failure.
OpenFileStore(filename As String, readOnly As Long) As Long
(Relevant only when running on a Microsoft Windows operating system.) Opens a file-based certificate store. Once loaded, the certificates within the store may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate contained in the store. Returns 1 for success, 0 for failure.
OpenLocalSystemStore(readOnly As Long) As Long
(Relevant only when running on a Microsoft Windows operating system.) 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. Once loaded, the certificates within the store may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate contained in the store. Returns 1 for success, 0 for failure.
OpenOutlookStore(readOnly As Long) As Long
(Relevant only when running on a Microsoft Windows operating system.) 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. Once loaded, the certificates within the store may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate contained in the store. Returns 1 for success, 0 for failure.
OpenRegistryStore(regRoot As String, regPath As String, readOnly As Long) As Long
(Relevant only when running on a Microsoft Windows operating system.) Opens an arbitrary registry-based certificate store. regRoot must be "CurrentUser" or "LocalMachine". regPath is a registry path such as "Software/MyApplication/Certificates". Once loaded, the certificates within the store may be searched via the Find* methods. It is also possible to iterate from 0 to NumCertficates-1, calling GetCertificate for each index, to retrieve each certificate contained in the store. Returns 1 for success, 0 for failure.
RemoveCertificate(cert As ChilkatCert)
(Relevant only when running on a Microsoft Windows operating system.) Removes the passed certificate from the store. The certificate object passed as the argument can no longer be used once removed. Returns 1 for success, 0 for failure.
SaveLastError(filename As String)
Saves the last error information to an XML formatted file.
|