CertStore C Library Reference
CertStore
* This is a freeware class/C library/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.
Create/Dispose
HCkCertStore CkCertStore_Create(void);
Creates an instance of the CkCertStore object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.
void CkCertStore_Dispose(HCkCertStore handle);
Objects created by calling CkCertStore_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.
C "Properties"
void CkCertStore_getLastErrorHtml(HCkCertStore cHandle, HCkString retval);
Error information in HTML format for the last method called.
void CkCertStore_getLastErrorText(HCkCertStore cHandle, HCkString retval);
Error information in plain-text format for the last method called.
void CkCertStore_getLastErrorXml(HCkCertStore cHandle, HCkString retval);
Error information in XML format for the last method called.
long CkCertStore_getNumCertificates(HCkCertStore cHandle);
The number of certificates held in the certificate store.
long CkCertStore_getNumEmailCerts(HCkCertStore cHandle);
The number of certificates that can be used for sending secure email within this store.
BOOL CkCertStore_getUtf8(HCkCertStore cHandle); void CkCertStore_putUtf8(HCkCertStore cHandle, BOOL newVal);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
void CkCertStore_getVersion(HCkCertStore cHandle, HCkString retval);
The version of this component, such as "1.0"
C "Methods"
BOOL CkCertStore_AddCertificate(HCkCertStore cHandle, HCkCert cert);
Adds a certificate to the store. If the certificate is already in the store, it is updated with the new information.
BOOL CkCertStore_CreateFileStore(HCkCertStore cHandle, const char *filename);
Creates a new file-based certificate store. Certificates may be saved to this store by calling AddCertificate. Returns TRUE for success, FALSE for failure.
BOOL CkCertStore_CreateMemoryStore(HCkCertStore cHandle);
Creates an in-memory certificate store. Certificates may be added by calling AddCertificate. Returns TRUE for success, FALSE for failure.
BOOL CkCertStore_CreateRegistryStore(HCkCertStore cHandle, const char *regRoot, const char *regPath);
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.
HCkCert CkCertStore_FindCertByRfc822Name(HCkCertStore cHandle, const char *name);
Locates a certificate by its RFC 822 name and returns it if found. Otherwise returns NULL.
HCkCert CkCertStore_FindCertBySerial(HCkCertStore cHandle, const char *serialNumber);
Finds and returns the certificate that has the matching serial number.
HCkCert CkCertStore_FindCertBySha1Thumbprint(HCkCertStore cHandle, const char *str);
Finds a certificate by it's SHA-1 thumbprint. The thumbprint is a hexidecimal string.
HCkCert CkCertStore_FindCertBySubject(HCkCertStore cHandle, const char *subject);
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.
HCkCert CkCertStore_FindCertBySubjectCN(HCkCertStore cHandle, const char *commonName);
Finds a certificate where the SubjectCN property (common name) matches exactly (but case insensitive) with the passed string.
HCkCert CkCertStore_FindCertBySubjectE(HCkCertStore cHandle, const char *emailAddress);
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.
HCkCert CkCertStore_FindCertBySubjectO(HCkCertStore cHandle, const char *organization);
Finds a certificate where the SubjectO property (organization) matches exactly (but case insensitive) with the passed string.
HCkCert CkCertStore_FindCertForEmail(HCkCertStore cHandle, const char *emailAddress);
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.
HCkCert CkCertStore_GetCertificate(HCkCertStore cHandle, long index);
Returns the Nth certificate in the store. The first certificate is at index 0.
HCkCert CkCertStore_GetEmailCert(HCkCertStore cHandle, long index);
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.
BOOL CkCertStore_LoadPfxData(HCkCertStore cHandle, HCkByteData pfxData, const char *password);
Loads a PFX from an in-memory image of a PFX file. Returns TRUE for success, FALSE for failure.
BOOL CkCertStore_LoadPfxData2(HCkCertStore cHandle, const unsigned char *buf, unsigned long bufLen, const char *password);
Loads a PFX from an in-memory image of a PFX file. Returns TRUE for success, FALSE for failure.
BOOL CkCertStore_LoadPfxFile(HCkCertStore cHandle, const char *filename, const char *password);
Loads a PFX file. Returns TRUE for success, FALSE for failure.
BOOL CkCertStore_OpenChilkatStore(HCkCertStore cHandle, BOOL readOnly);
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.
BOOL CkCertStore_OpenCurrentUserStore(HCkCertStore cHandle, BOOL readOnly);
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.
BOOL CkCertStore_OpenFileStore(HCkCertStore cHandle, const char *filename, BOOL readOnly);
Opens a file-based certificate store. Returns TRUE for success, FALSE for failure.
BOOL CkCertStore_OpenOutlookStore(HCkCertStore cHandle, BOOL readOnly);
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.
BOOL CkCertStore_OpenRegistryStore(HCkCertStore cHandle, const char *regRoot, const char *regPath, BOOL readOnly);
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.
BOOL CkCertStore_RemoveCertificate(HCkCertStore cHandle, HCkCert cert);
Removes the passed certificate from the store. The certificate object passed as the argument can no longer be used once removed.
BOOL CkCertStore_SaveLastError(HCkCertStore cHandle, const char *filename);
Saves the last error information to an XML formatted file.
const char *CkCertStore_lastErrorHtml(HCkCertStore cHandle);
Error information in HTML format for the last method called.
const char *CkCertStore_lastErrorText(HCkCertStore cHandle);
Error information in plain-text format for the last method called.
const char *CkCertStore_lastErrorXml(HCkCertStore cHandle);
Error information in XML format for the last method called.
const char *CkCertStore_version(HCkCertStore cHandle);
The version of this component, such as "1.0"
|