(Ruby) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within. Note: This example requires Chilkat v10.1.2 or greater.
require 'chilkat'
certStore = Chilkat::CkCertStore.new()
pfxPath = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
pfxPassword = "test"
success = certStore.LoadPfxFile(pfxPath,pfxPassword)
if (success != true)
print certStore.lastErrorText() + "\n";
exit
end
numCerts = certStore.get_NumCertificates()
print "PFX contains " + numCerts.to_s() + " certificates" + "\n";
cert = Chilkat::CkCert.new()
i = 0
while i < numCerts
certStore.GetCert(i,cert)
print i.to_s() + ": (Common Name) " + cert.subjectCN() + "\n";
print i.to_s() + ": (Serial Number) " + cert.serialNumber() + "\n";
print i.to_s() + ": (Distinguished Name) " + cert.subjectDN() + "\n";
i = i + 1
end
|