Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create CSR using existing private key

What I am trying to do is, create a CSR and with a private key that is password protected (the key).

In OpenSSL I can create a private key with a password like so:

openssl genrsa -des3 -out privkey.pem 2048 

Is there some way I can use the key I just created and generate a CSR using the key?

If not is there some way I can generate a CSR along with a PASSWORD PROTECTED private key?

like image 213
boyco Avatar asked Feb 27 '12 19:02

boyco


People also ask

Do you need private key to generate CSR?

A CSR is actually a request to get a certificate that is created and digitally signed by a CA, without having to send the private key over the internet.


1 Answers

This is the second example from the documentation of OpenSSL req:

Create a private key and then generate a certificate request from it:

openssl genrsa -out key.pem 2048 openssl req -new -key key.pem -out req.pem 

Note that, if you do this directly with req (see 3rd example), if you don't use the -nodes option, your private key will also be encrypted:

openssl req -newkey rsa:2048 -keyout key.pem -out req.pem 

(Despite what the documentation says, it's not exactly the same as the second example, since it doesn't use -des3, but you would have done so anyway.)

like image 79
Bruno Avatar answered Oct 10 '22 21:10

Bruno