How to extract the public key from a certificate . pem with Openssl

Asked

Viewed 1,889 times

0

The command below generates a certificate .pem (equal to those used by AWS):

openssl genrsa -des3 -out chaveprivada.pem 2048

However public and private keys are stored together in the archive. How to extract public key from file .pem?

2 answers

0


To extract the key from a file .pem use the command below:

openssl rsa -in chaveprivada.pem -pubout > chavepublica.pub

The public key will be written in the file chavepublica.pub.

-1

Private key is one thing Certificate and another. in the example I send the certificate and private key root@criativo:/home/edpes/SSLtest# openssl req -nodes -x509 -sha256 -newkey rsa:4096 -keyout edpesPV.key -out edpesKey.crt -days 365 -subj "/C=NL/ST=Zuid Brasil/L=SaoPaulo O=Edson Pessotti OU=IT Dept/CN=”edpes Sign Key" Generating a 4096 bit RSA private key ........................................................++ ......++

writing new private key to 'edpesPV.key'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.