(Go) Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem
How to output the public part of a private key:
Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem
pkey := chilkat.NewPrivateKey()
// Load the private key from an PEM file:
success := pkey.LoadPemFile("private.pem")
if success != true {
fmt.Println(pkey.LastErrorText())
pkey.DisposePrivateKey()
return
}
pubKey := pkey.GetPublicKey()
if pkey.LastMethodSuccess() == false {
fmt.Println(pkey.LastErrorText())
pkey.DisposePrivateKey()
return
}
success = pubKey.SavePemFile(false,"pubKey.pem")
if success != true {
fmt.Println(pubKey.LastErrorText())
pubKey.DisposePublicKey()
pkey.DisposePrivateKey()
return
}
fmt.Println("Success.")
pubKey.DisposePublicKey()
pkey.DisposePrivateKey()
|