C++
C++
Load PFX (PKCS#12) and List Certificates
See more Certificates Examples
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.Chilkat C++ Downloads
#include <CkCertStore.h>
#include <CkCert.h>
void ChilkatSample(void)
{
bool success = false;
CkCertStore certStore;
const char *pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx";
const char *pfxPassword = "test";
success = certStore.LoadPfxFile(pfxPath,pfxPassword);
if (success != true) {
std::cout << certStore.lastErrorText() << "\r\n";
return;
}
int numCerts = certStore.get_NumCertificates();
std::cout << "PFX contains " << numCerts << " certificates" << "\r\n";
CkCert cert;
int i = 0;
while (i < numCerts) {
certStore.GetCert(i,cert);
std::cout << i << ": (Common Name) " << cert.subjectCN() << "\r\n";
std::cout << i << ": (Serial Number) " << cert.serialNumber() << "\r\n";
std::cout << i << ": (Distinguished Name) " << cert.subjectDN() << "\r\n";
i = i + 1;
}
}