ssl-guides 2026-12-02 ⏱ 4 min read

What Is a Private Key in SSL?

What Is a Private Key in SSL?

A private key in SSL is the secret half of the key pair behind every certificate. The public key goes into the certificate and is shared with everyone. The private key stays on your server and is the one thing that proves your server really owns the certificate. Anyone who gets a copy can impersonate your site.

What the private key does in the handshake

  • It signs data during the TLS handshake to prove you hold the key that matches the certificate.
  • In older key exchange modes, it also helped decrypt session keys.
  • It never travels over the network and is never sent to the CA.

The CA only sees your public key, inside the CSR. That is why a CA never needs, and should never ask for, your private key.

Generate a private key

openssl genrsa -out example.key 2048

# Or an elliptic curve key
openssl ecparam -genkey -name prime256v1 -out ec.key

RSA 2048 and ECDSA with the P-256 curve are both common choices today. Check your CA and your platform for current recommendations. Create the key on the server where it will be used when possible.

Protect the private key

DoDo not
Set file mode 600 and limit the ownerEmail or chat the key
Store it only on servers that need itCommit it to a Git repository
Use a secrets manager for deploymentLeave copies in backups nobody watches
Generate a new key at renewalReuse one key for years
Consider a hardware module for high-value keysShare one key across many unrelated sites
chmod 600 example.key
chown root:root example.key

Match key and certificate

If the key and certificate do not belong together, the server will not start or will fail the handshake. Compare their moduli or public keys:

openssl x509 -in cert.pem -noout -pubkey | sha256sum
openssl pkey -in example.key -pubout | sha256sum

The two hashes must be identical. For a step-by-step guide, read Check If a Certificate Matches Its Private Key.

If a key leaks

  1. Generate a new key and CSR immediately.
  2. Get a new certificate and install it.
  3. Ask the CA to revoke the old certificate, if you believe misuse is possible.
  4. Find out how it leaked and close that path.
  5. Review any systems that stored or processed the old key.

Password-protected keys

A key can be encrypted with a passphrase. That adds protection on disk but means the server needs the passphrase to start. Many automated setups skip it and rely on file permissions instead. Choose based on your operations. Java stores keys inside keystores, which have their own passwords. See converting PEM to a Java keystore and installing SSL on Tomcat.

Wildcard keys need extra care

A wildcard certificate means one key across many hosts. Limit how many machines hold it. Our agency SSL guide discusses sharing keys across client sites, and the provider comparison explains how free CAs handle issuance.

Common questions

Can I recover a lost private key?

No. If you lose it and have no backup, you must generate a new key pair and get a new certificate. That is quick with a free CA.

Does the CA keep a copy?

A normal CA does not. If a provider generates the key for you, it has seen the key, so understand that before you rely on it for sensitive systems.

RSA or ECDSA?

Both are accepted by modern browsers. ECDSA keys are smaller and faster. RSA has the widest compatibility with old systems. Pick one, and confirm that your server and CA support it.

Where should it live in a container setup?

Mount it as a secret at runtime. Do not bake it into an image, because images get copied and pushed to registries.

Rotation routine

A simple routine works well: every renewal creates a new key, installs it with the new certificate, then securely deletes the old key. Automated clients can do this with a single option. Fewer old keys on disk means fewer things to leak and fewer questions during an audit.

Related reading: what happens when a key leaks and self-signed certificates.

Frequently Asked Questions

Can I recover a lost private key?

No. If you lose it and have no backup, you must generate a new key pair and get a new certificate. That is quick with a free CA.

Does the CA keep a copy?

A normal CA does not. If a provider generates the key for you, it has seen the key, so understand that before you rely on it for sensitive systems.

RSA or ECDSA?

Both are accepted by modern browsers. ECDSA keys are smaller and faster. RSA has the widest compatibility with old systems. Pick one, and confirm that your server and CA support it.

Where should it live in a container setup?

Mount it as a secret at runtime. Do not bake it into an image, because images get copied and pushed to registries.

Can two servers share one private key?

Yes, and that is what a load balancer pool does. Every extra copy is another place it can leak, so keep the number of holders as small as the setup allows.

🔒 Test Your Website SSL Certificate Now
Run Free SSL Check →

✅ 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 www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant