Chilkat VB.NET CertStore Class Reference
CertStore
* 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
(C#)
Chilkat.CertStore obj = new Chilkat.CertStore();
(VB.NET)
Dim obj As New Chilkat.CertStore()
Properties
LastErrorHtml As String (ReadOnly)
Error information in HTML format for the last method called.
LastErrorText As String (ReadOnly)
Error information in plain-text format for the last method called.
LastErrorXml As String (ReadOnly)
Error information in XML format for the last method called.
NumCertificates As Integer (ReadOnly)
The number of certificates held in the certificate store.
NumEmailCerts As Integer (ReadOnly)
The number of certificates that can be used for sending secure email within this store.
Version As String (ReadOnly)
The version of this component, such as "1.0"
Methods
Function AddCertificate(ByVal cert As Cert) As Boolean
Adds a certificate to the store. If the certificate is already in the store, it is updated with the new information.
Function CreateFileStore(ByVal filename As String) As Boolean
Creates a new file-based certificate store. Certificates may be saved to this store by calling AddCertificate. Returns true for success, false for failure.
Function CreateMemoryStore() As Boolean
Creates an in-memory certificate store. Certificates may be added by calling AddCertificate. Returns true for success, false for failure.
Function CreateRegistryStore(ByVal regRoot As String, ByVal regPath As String) As Boolean
Creates a registry-based certificate store. regRoot must be "CurrentUser" or "LocalMachine". regPath is a registry path such as "Software/MyApplication/Certificates". Returns true for success, false for failure.
Function FindCertByRfc822Name(ByVal name As String) As Cert
Locates a certificate by its RFC 822 name and returns it if found. Otherwise returns NULL.
Function FindCertBySerial(ByVal str As String) As Cert
Finds and returns the certificate that has the matching serial number.
Function FindCertBySha1Thumbprint(ByVal str As String) As Cert
Finds a certificate by it's SHA-1 thumbprint. The thumbprint is a hexidecimal string.
Function FindCertBySubject(ByVal str As String) As Cert
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(ByVal str As String) As Cert
Finds a certificate where the SubjectCN property (common name) matches exactly (but case insensitive) with the passed string.
Function FindCertBySubjectE(ByVal str As String) As Cert
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(ByVal str As String) As Cert
Finds a certificate where the SubjectO property (organization) matches exactly (but case insensitive) with the passed string.
Function FindCertForEmail(ByVal emailAddress As String) As Cert
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(ByVal index As Integer) As Cert
Returns the Nth certificate in the store. The first certificate is at index 0.
Function GetEmailCert(ByVal index As Integer) As Cert
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(ByVal pfxData As Byte(), ByVal password As String) As Boolean
Loads a PFX from an in-memory image of a PFX file. Returns true for success, false for failure.
Function LoadPfxFile(ByVal pfxFilename As String, ByVal password As String) As Boolean
Loads a PFX file. Returns true for success, false for failure.
Function OpenChilkatStore(ByVal readOnly As Boolean) As Boolean
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 = true if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = true will prevent many "permission denied" errors. Returns true for success, false for failure.
Function OpenCurrentUserStore(ByVal readOnly As Boolean) As Boolean
Opens the registry-based current-user certificate store. Set readOnly = true if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = true will prevent many "permission denied" errors. Returns true for success, false for failure.
Function OpenFileStore(ByVal filename As String, ByVal readOnly As Boolean) As Boolean
Opens a file-based certificate store. Returns true for success, false for failure.
Function OpenOutlookStore(ByVal readOnly As Boolean) As Boolean
Opens the registry-based certificate store used by Outlook. Set readOnly = true if you are only fetching certificates and not updating the certificate store (i.e. you are not adding or removing certificates). Setting readOnly = true will prevent many "permission denied" errors. Returns true for success, false for failure.
Function OpenRegistryStore(ByVal regRoot As String, ByVal regPath As String, ByVal readOnly As Boolean) As Boolean
Opens an arbitrary registry-based certificate store. regRoot must be "CurrentUser" or "LocalMachine". regPath is a registry path such as "Software/MyApplication/Certificates". Returns true for success, false for failure.
Function RemoveCertificate(ByVal cert As Cert) As Boolean
Removes the passed certificate from the store. The certificate object passed as the argument can no longer be used once removed.
Function SaveLastError(ByVal filename As String) As Boolean
Saves the last error information to an XML formatted file.
|