Search code examples
sslopensslcertificate

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?


Solution

  • 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.)