Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate CSR for SSL that works with Nginx & Apache?

I want to generate the CSR file for requesting SSL (wildcard) certificate. This certificate and private key will be used on multiple machines with both Apache and Nginx.

RapitSSL states the following commands for the different setups:

  • Nginx

    $ openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr

  • Apache Mod SSL

    $ openssl genrsa -des3 -out <private key file name>.key 2048

  • Apache-SSL

    $ openssl genrsa -des3 -out www.yourdomain-example.com.key 2048

Is there a way to generate a CSR that works with both Apache and Nginx?

like image 252
ptz0n Avatar asked Nov 04 '12 18:11

ptz0n


1 Answers

  • Apache Mod SSL

    $ openssl genrsa -des3 -out < private key file name>.key 2048

  • Apache-SSL

    $ openssl genrsa -des3 -out www.yourdomain-example.com.key 2048

These two are obviously the exact same command, with a different way of writing the example name. They just generate the key pair, you'd need an additional req command to generate a CSR too.

genrsa generates a key pair, and req generates a CSR. However, req can perform both operations at once when using -newkey.

See OpenSSL req example documentation:

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

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

The same but just using req:

openssl req -newkey rsa:1024 -keyout key.pem -out req.pem
like image 188
Bruno Avatar answered Nov 15 '22 03:11

Bruno