-
Notifications
You must be signed in to change notification settings - Fork 139
Generating SSL Server CSR with OpenSSL
Endi S. Dewata edited this page Jan 20, 2022
·
3 revisions
To generate RSA key:
$ openssl genrsa -out sslserver.key 2048 $ openssl rsa -in sslserver.key -pubout -out sslserver.pub
To generate ECC key:
$ openssl ecparam -name secp256k1 -genkey -noout -out sslserver.key $ openssl ec -in sslserver.key -pubout -out sslserver.pub
To generate a certificate request with a new key:
$ openssl req \ -newkey rsa:2048 \ -nodes \ -keyout sslserver.key \ -new \ -subj "/CN=$HOSTNAME" \ -days 365 \ -out sslserver.csr
To generate a certificate request with an existing key:
$ openssl req \ -key sslserver.key \ -nodes \ -new \ -subj "/CN=$HOSTNAME" \ -days 365 \ -out sslserver.csr
To generate a certificate request with SAN, prepare a configuration file (e.g. san.cnf):
[ req ] default_bits = 2048 distinguished_name = req_distinguished_name req_extensions = req_ext [ req_distinguished_name ] commonName = pki.example.com [ req_ext ] subjectAltName = @alt_names [alt_names] DNS.1 = www.example.com DNS.2 = www.example.org
Then execute the following command:
$ openssl req \ -config san.cnf \ -newkey rsa:2048 \ -nodes \ -keyout private.key \ -out sslcert.csr
Tip
|
To find a page in the Wiki, enter the keywords in search field, press Enter, then click Wikis. |