Is there any way we can convert RSA private key to x509 format?

Viewed 7913

I have created private key and public key using below commands,

openssl genrsa -out privatekey.pem 1024

openssl req -new -x509 -key privatekey.pem -out publickey.cer -days 1825

Seems like both are in different format. I need to convert rsa privatekey.pem to x509 format.

Is there any way i can do that?

1 Answers

Probably, you meant a conversion of the RSA private key (starting with -----BEGIN RSA PRIVATE KEY-----) to the PKCS8 format (starting with -----BEGIN PRIVATE KEY-----). If so, use the following command:

openssl pkcs8 -topk8 -in rsa.private.key -out pkcs8.private.key -nocrypt

Related