(Go) 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.
certStore := CertStore_Ref.html">chilkat.NewCertStore()
var success bool
pfxPath := "/Users/chilkat/testData/pfx/chilkat_ssl.pfx"
pfxPassword := "test"
success = certStore.LoadPfxFile(pfxPath,pfxPassword)
if success != true {
fmt.Println(certStore.LastErrorText())
certStore.DisposeCertStore()
return
}
numCerts := certStore.NumCertificates()
fmt.Println("PFX contains ", numCerts, " certificates")
cert := Cert_Ref.html">chilkat.NewCert()
i := 0
for i < numCerts {
certStore.GetCert(i,cert)
fmt.Println(i, ": (Common Name) ", cert.SubjectCN())
fmt.Println(i, ": (Serial Number) ", cert.SerialNumber())
fmt.Println(i, ": (Distinguished Name) ", cert.SubjectDN())
i = i + 1
}
certStore.DisposeCertStore()
cert.DisposeCert()
|