Back to Articles
Reference2026-11-07•8 min read•CSR.plus Team

OpenSSL CSR Commands: RSA, ECDSA, SAN and Common Errors

OpenSSL CSR Commands: RSA, ECDSA, SAN and Common Errors

The one command most people need

openssl req -new -newkey rsa:2048 -nodes \
  -keyout privkey.pem -out request.csr \
  -subj "/CN=example.com" \
  -addext "subjectAltName=DNS:example.com,DNS:www.example.com"

Read it as: create a new request, generate a new key along with it, do not encrypt the key output (-nodes), write the key to privkey.pem and the request to request.csr, set the subject to CN=example.com, and add a SAN extension covering the apex and www host.

Two flags trip people up:

  • -nodes (short for "no DES") means the private key is written in the clear. Remove it and you will be prompted for a passphrase, which most servers cannot use at boot.
  • -addext requires OpenSSL 1.1.1+. On older builds the command silently lacks SAN support.

RSA 4096

Same command, larger key:

openssl req -new -newkey rsa:4096 -nodes \
  -keyout privkey.pem -out request.csr \
  -subj "/CN=example.com" \
  -addext "subjectAltName=DNS:example.com,DNS:www.example.com"

4096-bit RSA costs noticeably more CPU per handshake for a modest security gain. If you want stronger crypto, ECDSA is the better trade.

ECDSA P-256 and P-384

openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
  -keyout privkey.pem -out request.csr \
  -subj "/CN=example.com" \
  -addext "subjectAltName=DNS:example.com,DNS:www.example.com"

Swap prime256v1 for secp384r1 if the CA requires 384-bit ECDSA. Note that some older Android and Windows stacks still fail on ECDSA chains — check your traffic before switching.

Many SANs, or an IP address

For a long SAN list, -addext becomes unwieldy. Use a config file:

# csr.cnf
[req]
default_bits       = 2048
prompt             = no
default_md         = sha256
distinguished_name = dn
req_extensions     = v3_req

[dn]
CN = example.com

[v3_req]
subjectAltName = @alt_names

[alt_names]
DNS.1 = example.com
DNS.2 = www.example.com
DNS.3 = api.example.com
IP.1  = 192.0.2.10
openssl req -new -newkey rsa:2048 -nodes \
  -keyout privkey.pem -out request.csr -config csr.cnf

The req_extensions line is the one that matters. Without it you get a perfectly valid CSR with no SAN at all — and a CA rejection that says the names do not match.

Check what you built before submitting

openssl req -in request.csr -noout -text

Look for:

  • Subject Alternative Name with all expected hostnames
  • Public-Key line showing 2048 bit (or id-ecPublicKey with the right curve)
  • Signature Algorithm such as sha256WithRSAEncryption

Then verify the signature is internally consistent:

openssl req -in request.csr -noout -verify

A healthy file prints verify OK. If it prints "unable to load", the file is truncated — usually because it was copied out of a terminal that wrapped lines.

Error messages and what they actually mean

MessageReal causeFix
Error unpacking CSRFile is DER, not PEM, or has stray textConvert: openssl req -inform DER -in request.der -out request.csr
no start linePEM header missing or line endings mangledVerify the file starts with -----BEGIN CERTIFICATE REQUEST-----
error adding extension-addext on OpenSSL 1.0.2Use a config file
unable to load private keyPassphrase-protected keyAdd -passin pass:... or regenerate without -passphrase
CSR accepted but names rejectedSAN missing or CN onlyRegenerate with -addext

Match the CSR to its key

Before you deploy, confirm the certificate you get back belongs to the key on the server:

openssl req -in request.csr -noout -pubkey
openssl pkey -in privkey.pem -pubout

The two blocks must be byte-identical. If they differ, you are about to install a certificate that does not match your key — the classic cause of ssl_error_no_cypher_overlap and "key values mismatch" from nginx.

The key-match tool does the same comparison in the browser, without copying private key material anywhere.

Why bother with the CLI at all

Because it is reproducible. A CSR generated on a laptop by clicking through a form is hard to audit; a command in a runbook can be reviewed, re-run and versioned. Keep the command next to the deploy script, and never commit privkey.pem — only the CSR is safe to store in a repository.

FAQ

Which OpenSSL version supports -addext?

1.1.1 and newer. On CentOS 7 or older macOS builds you may be on 1.0.2, where -addext does not exist — use a config file with [v3_req] instead.

Why does my CSR have no SAN even though I passed -subj?

-subj only sets the subject (CN). SAN comes from -addext or the config file. A CSR built with -subj alone is rejected by every modern CA because browsers ignore CN.

How do I verify a CSR matches a private key?

Compare the public key of both: openssl req -in request.csr -noout -pubkey and openssl pkey -in privkey.pem -pubout should print identical blocks.

Can a CSR contain an IP address?

Yes, use IP:192.0.2.10 in the SAN list. Public CAs rarely issue for public IPs, but internal CAs and Let’s Encrypt staging setups do.

Free SSL/TLS tools

Verify and inspect your certificates in seconds.

Related Certificate Info

Learn more about choosing and buying certificates.

Related articles