Private Key Generator: Generate a Key and CSR
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.key to create a 2048-bit RSA key, or use an ECDSA P-256 key for smaller and faster certificates. Create a CSR from it, keep the key private, and never share it with anyone, including your certificate authority.Private key generator: choose a key type
| Type | Size | Notes |
|---|---|---|
| RSA | 2048 bits (3072 or 4096 for extra margin) | Works everywhere, larger and slower |
| ECDSA | P-256 (prime256v1) | Smaller, faster, supported by all modern clients |
RSA 2048 remains the safest choice for compatibility with older systems. ECDSA P-256 is a good choice for modern servers. Avoid keys under 2048 bits for RSA.
Private key generator: generate the key
# RSA 2048
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.key
# ECDSA P-256
openssl ecparam -name prime256v1 -genkey -noout -out ec-private.key
If you prefer a browser tool, the OpenSSL generator builds the commands for you. Note that anything generated on a remote website is only as private as that website, so for production keys run the commands on your own machine or server.
Create the CSR
openssl req -new -key private.key -out example.com.csr \
-subj "/CN=example.com" \
-addext "subjectAltName=DNS:example.com,DNS:www.example.com"
The subject alternative names are what browsers actually check, so list every hostname. The CSR generator is a form-based alternative. Inspect the result before submitting:
openssl req -in example.com.csr -noout -text | head -30
Protect the key
- Permissions:
chmod 600 private.keyand owned by the account that runs the web server or root. - Never email it, paste it into chat or commit it to Git.
- Optional passphrase: add one with
openssl pkey -in private.key -aes256 -out private.enc.key. Servers then need the passphrase at start, which complicates automatic restarts. - Back up securely in an encrypted location.
- Replace it if it may have been exposed. Reissue the certificate with a fresh key.
Make sure the pieces match
A frequent installation error is a certificate that does not match the key. Confirm with the key matcher, or compare hashes:
openssl pkey -in private.key -pubout | sha256sum
openssl x509 -in certificate.crt -pubkey -noout | sha256sum
Identical hashes mean the pair matches. If you need a different file format for Windows or IIS, read how to convert PEM to PFX.
Do you need your own key at all?
If you use Certbot or a panel's built-in Let's Encrypt feature, it generates and stores the key for you, and renewals can make a new key each time. Generate a key yourself when a provider asks for a CSR, when you use a hardware appliance, or when you want a specific key type.
Related reading: the CSR generator, the full key and CSR guide and the CSR generator.
Frequently Asked Questions
Is it safe to use an online key generator?
For learning and testing, yes. For production, generate keys on your own system so the key never travels.
Can I reuse the same key for a new certificate?
You can, but a fresh key at each renewal is better practice.
What if I lose the private key?
It cannot be recovered. Generate a new key and CSR and have the certificate reissued.
Should I use a passphrase?
It adds protection at rest, but unattended servers usually run unencrypted keys with tight file permissions.
Is it safe to generate a key in the browser?
For testing, yes. For production, generate it on the server so it never travels. A key made in a browser has passed through someone else's page.
Is a 2048-bit RSA key still enough?
Yes. 2048-bit RSA is the common default and matches what most certificate authorities and servers accept. A 4096-bit key is slower to generate and use, and adds no practical benefit for a website certificate. An ECDSA P-256 key is smaller and faster when your server and visitors support it.
✅ 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.