OpenSSL "pkey -pubout" - Extract EC Public Key

Q

How to extract the public key from a EC key file using OpenSSL "pkey" command?

✍: FYIcenter.com

A

If you want to extract the public key out from a EC key file (private key an public key), you can use the OpenSSL "pkey -pubout" command as shown below:

C:\Users\fyicenter>\local\openssl\openssl.exe

OpenSSL> pkey -in my_ec.key -pubout -out my_ec_pub.key
OpenSSL> exit

C:\Users\fyicenter>type my_ec_pub.key
-----BEGIN PUBLIC KEY-----
MIG6MIGXBgcqhkjOPQIBMIGLAgEBMBoGByqGSM49AQECDwDbfCq/YuNeZoB2vq0g
izA3BA7bfCq/YuNeZoB2vq0giAQOZZ74ugQ5Fu7eiRFwKyIDFQAA9QsCjk1pbmdo
dWFRdSkEcng/sQQdBAlIcjmZWl7na1X5wvCYqJzlr4ckwKI+Dg/3dQACDwDbfCq/
YuNedijfrGVhxQIBAQMeAATKt2umhaULWqO58OmQMLMsCykE4cor/fRTiA2d
-----END PUBLIC KEY-----

Options used in this command are:

  • "-in my_ec.key" - Read the EC key file from: C:\Users\fyicenter\my_ec.key
  • "-pubout" - Extract the public key out of the EC key file
  • "-out my_ec_pub.key" - Save the public key in a file with no password protection.

 

OpenSSL "genpkey" Command for EC Keys

⇒⇒OpenSSL Tutorials

2017-07-03, 347👍, 0💬