(Go) Load Certificate from .cer and Private Key from .pem
Load a certificate from a .cer and its associated private key from a .pem.
cert := chilkat.NewCert()
success := cert.LoadFromFile("C:/certs_and_keys/Certificate.cer")
if success == false {
fmt.Println(cert.LastErrorText())
cert.DisposeCert()
return
}
sbPem := chilkat.NewStringBuilder()
success = sbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem","utf-8")
if success == false {
fmt.Println("Failed to load private key PEM")
cert.DisposeCert()
sbPem.DisposeStringBuilder()
return
}
success = cert.SetPrivateKeyPem(*sbPem.GetAsString())
if success == false {
fmt.Println(cert.LastErrorText())
cert.DisposeCert()
sbPem.DisposeStringBuilder()
return
}
fmt.Println("The certificate and associated private key are now loaded and ready for signing.")
cert.DisposeCert()
sbPem.DisposeStringBuilder()
|