(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
Note: This example requires Chilkat v11.0.0 or greater.
success := false
pkey := PrivateKey_Ref.html">chilkat.NewPrivateKey()
// Load the private key from an PEM file:
success = pkey.LoadPemFile("private.pem")
if success == false {
fmt.Println(pkey.LastErrorText())
pkey.DisposePrivateKey()
return
}
pubKey := PublicKey_Ref.html">chilkat.NewPublicKey()
pkey.ToPublicKey(pubKey)
success = pubKey.SavePemFile(false,"pubKey.pem")
if success != true {
fmt.Println(pubKey.LastErrorText())
pubKey.DisposePublicKey()
pkey.DisposePrivateKey()
pubKey.DisposePublicKey()
return
}
fmt.Println("Success.")
pkey.DisposePrivateKey()
pubKey.DisposePublicKey()
|