Skip to content

Creating Self Signed SSL Server Certificate with OpenSSL

Endi S. Dewata edited this page Oct 28, 2020 · 2 revisions

Creating Self-Signed SSL Server Certificate

To create a certificate with RSA key:

$ openssl req \
    -newkey rsa:2048 \
    -x509 \
    -nodes \
    -days 365 \
    -subj "/CN=$HOSTNAME" \
    -keyout sslserver.key \
    -out sslserver.crt

To create a certificate with ECC key:

$ openssl ecparam \
    -genkey \
    -name prime256v1 \
    -out sslserver.eckey
$ openssl pkcs8 \
    -topk8 \
    -nocrypt \
    -in sslserver.eckey \
    -out sslserver.key
$ openssl req \
    -new \
    -x509 \
    -nodes \
    -days 365 \
    -subj "/CN=$HOSTNAME" \
    -key sslserver.key \
    -out sslserver.crt

See Also

Clone this wiki locally