CkCertStore C++ Class Reference
CkCertStore
* 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.
Properties
bool get_AvoidWindowsPkAccess(void); void put_AvoidWindowsPkAccess(bool newVal);
Applies only when running on a Microsoft Windows operating system. If true, 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 false.
void LastErrorHtml(CkString &str);
Error information in HTML format for the last method called.
void LastErrorText(CkString &str);
Error information in plain-text format for the last method called.
void LastErrorXml(CkString &str);
Error information in XML format for the last method called.
long get_NumCertificates(void);
The number of certificates held in the certificate store.
bool get_Utf8(void) const; void put_Utf8(bool b);
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.
bool get_VerboseLogging(void); void put_VerboseLogging(bool newVal);
If set to true, then the LastErrorText may contain more verbose logging.
void get_Version(CkString &version);
The version of this component, such as "1.0"
Methods
CkCert * FindCertByRfc822Name(const char * name);
Locates a certificate by its RFC 822 name and returns it if found.
Returns NULL on failure.
CkCert * FindCertBySerial(const char * serialNumber);
Finds and returns the certificate that has the matching serial number.
Returns NULL on failure.
CkCert * FindCertBySha1Thumbprint(const char * str);
Finds a certificate by it's SHA-1 thumbprint. The thumbprint is a hexidecimal string.
Returns NULL on failure.
CkCert * FindCertBySubject(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.
Returns NULL on failure.
CkCert * FindCertBySubjectCN(const char * commonName);
Finds a certificate where the SubjectCN property (common name) matches exactly (but case insensitive) with the passed string
Returns NULL on failure.
CkCert * FindCertBySubjectE(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.
Returns NULL on failure.
CkCert * FindCertBySubjectO(const char * organization);
Finds a certificate where the SubjectO property (organization) matches exactly (but case insensitive) with the passed string.
Returns NULL on failure.
CkCert * GetCertificate(long index);
Returns the Nth certificate in the store. The first certificate is at index 0.
Returns NULL on failure.
bool LoadPfxData(CkByteData & pfxData, const char * password);
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 true for success, false for failure.
bool LoadPfxData2(const unsigned char * buf, unsigned long bufLen, const char * password);
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 true for success, false for failure.
bool LoadPfxFile(const char * filename, const char * password);
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 true for success, false for failure.
bool SaveLastError(const char * filename);
Saves the last error information to an XML formatted file.
const char * lastErrorHtml();
Error information in HTML format for the last method called.Returns a null on failure
const char * lastErrorText();
Error information in plain-text format for the last method called.Returns a null on failure
const char * lastErrorXml();
Error information in XML format for the last method called.Returns a null on failure
const char * version();
The version of this component, such as "1.0" Returns a null on failure
|