# What Is Private Key? Definition and Examples

> Private keys are the secret halves of asymmetric key pairs; in TLS, a server uses its private key to prove it owns the public key in its certificate.

Source: https://ssl.sh/glossary/private-key/
Last updated: 2026-11-10

A private key is the secret half of an asymmetric key pair such as [RSA](https://ssl.sh/glossary/rsa/) or ECDSA. Its matching [public key](https://ssl.sh/glossary/public-key/) is published in the certificate, while the private key stays on the server or in an [HSM](https://ssl.sh/glossary/hsm/). In a TLS 1.3 handshake the server signs the handshake transcript with its private key (the CertificateVerify message), proving that it is the legitimate holder of the certificate; the session's encryption keys come from a separate ephemeral key exchange.

## Why it matters
Whoever holds the private key can impersonate the site for as long as the certificate is valid and trusted. If a key leaks, you must revoke the certificate and obtain a new one with a new key, because a new certificate for the same key is just as exposed. With forward-secret key exchange (ECDHE), a stolen key does not decrypt previously recorded traffic; with the legacy RSA key exchange, it does. Keep key files readable only by the service account, and out of backups, tickets, chat messages and source control.

## Example
```bash
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out example.com.key
chmod 600 example.com.key
# check that a key and certificate belong together: the hashes must match
openssl pkey -in example.com.key -pubout | openssl sha256
openssl x509 -in example.com.crt -noout -pubkey | openssl sha256
```

## Common misconceptions
- **The CA has a copy of my private key.** Not if you generated the CSR yourself; the CA only ever sees the public key.
- **Revoking the certificate is enough after a leak.** You also need a new key pair.
- **A passphrase makes the key file safe anywhere.** Servers usually need the key unlocked at startup, so filesystem permissions and access control remain the main protection.

## Related terms

- [公钥](https://ssl.sh/zh/glossary/public-key/): 公钥是非对称密钥对中可以公开的一半，写在证书里，供他人验证由对应私钥生成的签名。
- [KEY 文件](https://ssl.sh/zh/glossary/key-file/): KEY 文件是按惯例存放私钥的 .key 文件，通常为 PEM 编码，但扩展名本身并不说明里面的具体格式。
- [CSR](https://ssl.sh/zh/glossary/csr/): CSR 是证书签名请求，包含申请者的公钥和希望写入证书的身份信息，用私钥签名后提交给 CA 以申请证书。
- [HSM](https://ssl.sh/zh/glossary/hsm/): HSM 是一种防篡改的硬件设备，在内部生成、保存并使用密钥，私钥不会以明文形式离开设备。
- [密钥轮换](https://ssl.sh/zh/glossary/key-rotation/): 密钥轮换是按计划或在安全事件后，用新生成的密钥替换旧密钥，以限制密钥泄露造成损失的做法。
- [前向保密](https://ssl.sh/zh/glossary/forward-secrecy/): 前向保密是密钥交换的一种安全属性：即使服务器的长期私钥日后泄露，过去连接的会话密钥也不会因此暴露。
- [证书吊销](https://ssl.sh/zh/glossary/revocation/): 证书吊销是 CA 在证书到期前宣布其作废的操作，通过 CRL 或 OCSP 对外公布，使客户端不再信任这张证书。
