Generate a Private Key and CSR with OpenSSL
To get a certificate you create a key pair. The private key stays on your server. The public key goes into a certificate signing request (CSR), which you send to the CA. This guide shows the commands for RSA and ECDSA, how to include several hostnames, and how to check the result.
Private key and CSR with OpenSSL: RSA 2048
openssl req -new -newkey rsa:2048 -nodes \
-keyout example.com.key -out example.com.csr \
-subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.com"The -nodes flag leaves the key unencrypted, which is normal for web servers that must start without a person typing a passphrase. The -addext flag needs OpenSSL 1.1.1 or newer.
Option 2: ECDSA P-256
openssl ecparam -genkey -name prime256v1 -noout -out example.com.key
openssl req -new -key example.com.key -out example.com.csr \
-subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.com"ECDSA keys are shorter and faster. Supported by all current browsers and servers. Choose RSA only if you must support very old clients.
RSA or ECDSA?
| RSA 2048 | ECDSA P-256 | |
|---|---|---|
| Compatibility | Everywhere | All modern clients |
| Key and signature size | Larger | Smaller |
| CPU cost of handshake | Higher | Lower |
| Common choice | Default of most tools | Good for new deployments |
Protect the private key
- Set strict permissions: chmod 600 example.com.key.
- Never email it, paste it into a chat or upload it to a website you do not control.
- Keep an encrypted backup. If you lose it, you must reissue the certificate.
- Do not commit it to a Git repository.
Generate in the browser
The CSR Generator creates a key and CSR without the command line, and the OpenSSL Command Generator builds the command for your options. Download the private key straight away and keep it private, because it is shown only once.
Private key and CSR with OpenSSL: verify first
openssl req -in example.com.csr -noout -text -verifyCheck the CN, the SAN list and the key size. Use the SSL Decoder if you prefer a browser view. Submit only the .csr file to the CA, never the .key file.
After issuance
Install the certificate, the intermediate chain and your private key on the server. Confirm that the certificate matches the key:
openssl x509 -in certificate.crt -noout -pubkey | openssl sha256
openssl pkey -in example.com.key -pubout | openssl sha256Both lines must be identical. Then run the SSL Checker on the live site. If you do not want to manage CSRs by hand, you can issue a free certificate on TryFreeSSL.
Reusing a key at renewal
You can reuse the key and CSR or generate new ones. A fresh key on every renewal is a better habit, because it limits what an old leaked backup is worth. Most ACME clients can do this automatically.
Practical notes
Keep a record of which key belongs to which certificate. A simple habit is to name files after the domain and the date, such as example.com-2026-12.key, and to store the CSR next to the key it came from. When a renewal arrives months later, you can then tell at a glance which key it needs, and avoid the key mismatch errors that come from mixing files. If several people manage servers, store keys in a secrets manager rather than in shared folders or tickets.
Related reading: installing a certificate on Tomcat, converting PEM to a Java keystore and protecting private keys.
Frequently Asked Questions
What is the difference between a CSR and a certificate?
The CSR is the request you send. The certificate is what the CA returns after validation, signed with the CA key.
Can I use the same CSR for several servers?
Technically yes, but then every server needs the same private key. It is safer to generate separate keys.
Which common name should I use?
Your primary domain. The SAN list is what browsers actually check, so list every name there.
I lost my private key. What now?
Generate a new key and CSR and have the certificate reissued. A certificate cannot work without its key.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.