Before a certificate authority can issue you a TLS certificate, you send it a certificate signing request, or CSR. A CSR is defined in RFC 2986 (PKCS #10): it bundles your distinguished name and your public key, optionally with extra attributes, and it is signed with your private key. That signature is the point. It proves to the CA that whoever submitted the request actually holds the private key matching the public key inside it. The CA verifies the signature, checks that you control the names in the request, and then builds an X.509 certificate from it. The CSR itself is not a certificate, and it contains no private key material, so it is safe to send to a CA.

Generate a key and CSR in one command

openssl req -new -newkey rsa:2048 -nodes -keyout securetron.net.key -out securetron.net.csr

What each part does:

  • req -new creates a new CSR.
  • -newkey rsa:2048 generates a fresh 2048-bit RSA private key at the same time.
  • -nodes writes the private key unencrypted, so a web server can load it at boot without prompting for a passphrase. Leave it off if you want the key passphrase-protected.
  • -keyout and -out choose where the private key and the CSR are saved.

OpenSSL then asks for the subject fields: country, state, organization, and common name. For a TLS certificate the common name should be the hostname, here securetron.net.

Include the SANs, not just the common name

Modern CAs put the hostnames in the subject alternative name (SAN) extension and largely ignore the common name, so add SANs explicitly. On OpenSSL 1.1.1 or newer, -addext does this inline, and -subj skips the interactive prompts:

openssl req -new -newkey rsa:2048 -nodes \
  -keyout securetron.net.key -out securetron.net.csr \
  -subj "/CN=securetron.net" \
  -addext "subjectAltName=DNS:securetron.net,DNS:www.securetron.net"

On older OpenSSL versions -addext does not exist; use a config file with a [req_ext] section instead.

Check the CSR before you send it

openssl req -in securetron.net.csr -noout -verify -text

This prints the subject, public key, and requested extensions, and confirms the self-signature verifies. Also confirm the key matches the CSR before handing anything to a CA:

openssl req -in securetron.net.csr -noout -pubkey | openssl pkey -pubin -outform der | openssl dgst -sha256
openssl pkey -in securetron.net.key -pubout -outform der | openssl dgst -sha256

The two hashes must be identical. If they are not, the CSR was built from a different key and the certificate the CA issues will not work with your key.

Prefer ECDSA? Same command, different key

openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes \
  -keyout securetron.net.key -out securetron.net.csr \
  -subj "/CN=securetron.net" \
  -addext "subjectAltName=DNS:securetron.net"

P-256 gives equivalent security to RSA 2048 with much smaller keys and faster handshakes. Check that your server and your CA both support it first.

A few things that trip people up

  • Never send the .key file to anyone. Only the .csr goes to the CA. The private key stays on your server.
  • One CSR per certificate. When you renew, generate a fresh key and a fresh CSR rather than reusing the old key.
  • If a CA rejects your CSR, the usual causes are a missing SAN, a subject field the CA does not accept, or a key that is too small. The -text output above shows exactly what the CA received, so check there first.

Sources: RFC 2986 (PKCS #10, https://www.rfc-editor.org/rfc/rfc2986.txt) and the OpenSSL req documentation (https://docs.openssl.org/master/man1/openssl-req/).