Ruby
Ruby
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 Ruby Downloads
require 'chilkat'
success = false
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