(Swift) Load PFX (PKCS#12) and List Certificates
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.
func chilkatTest() {
let certStore = CkoCertStore()!
var success: Bool
var pfxPath: String? = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
var pfxPassword: String? = "test"
success = certStore.loadPfxFile(pfxPath, password: pfxPassword)
if success != true {
print("\(certStore.lastErrorText!)")
return
}
var numCerts: Int = certStore.numCertificates.intValue
print("PFX contains \(numCerts) certificates")
var i: Int = 0
while i < numCerts {
var cert: CkoCert? = certStore.getCertificate(i)
print("\(i): (Common Name) \(cert!.subjectCN!)")
print("\(i): (Serial Number) \(cert!.serialNumber!)")
print("\(i): (Distinguished Name) \(cert!.subjectDN!)")
cert = nil
i = i + 1
}
}
|