(Go) Load PFX/P12 File into Certificate Store Object
Demonstrates how to load a .pfx/.p12 into a certificate store object.
certStore := chilkat.NewCertStore()
// This only loads the contents of the PFX file into the certStore object.
// It is not importing the PFX into the Windows certificate stores.
pfxPassword := "badssl.com"
success := certStore.LoadPfxFile("qa_data/pfx/badssl.com-client.p12",pfxPassword)
if success == false {
fmt.Println(certStore.LastErrorText())
certStore.DisposeCertStore()
return
}
// Examine each certificate (loaded from the PFX) in this certStore object
numCerts := certStore.NumCertificates()
i := 0
for i < numCerts {
cert := certStore.GetCertificate(i)
fmt.Println("hasPrivateKey=", *cert.HasPrivateKey(), ", ", cert.SubjectCN())
cert.DisposeCert()
i = i + 1
}
certStore.DisposeCertStore()
|