# What Is Public Key? Definition and Examples

> Public keys are the shareable halves of asymmetric key pairs, published in certificates so others can verify signatures made with the matching private key.

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

A public key is the half of an asymmetric key pair that can be shared freely. In an X.509 certificate it sits in the SubjectPublicKeyInfo (SPKI) field together with its algorithm, for example RSA, [ECDSA](https://ssl.sh/glossary/ecdsa/) on the P-256 curve, or Ed25519. The certificate exists to bind that public key to a name: the CA's [digital signature](https://ssl.sh/glossary/digital-signature/) over the certificate asserts that the key belongs to `example.com`. Anyone can use it to verify signatures made with the matching [private key](https://ssl.sh/glossary/private-key/), and with RSA it can also encrypt data that only the private key can decrypt.

## Why it matters
Clients use the server's public key to check the signature in the TLS handshake, which is how they know they are talking to the key holder and not an impostor. Hashes of the SPKI are used for [certificate pinning](https://ssl.sh/glossary/certificate-pinning/), DANE TLSA records and for checking that a key, CSR and certificate belong together. If a renewal keeps the same key pair, the SPKI hash stays the same even though the certificate changes, which is why pinning and key rotation must be planned together.

## Example
```bash
openssl x509 -in example.com.crt -noout -pubkey > example.com.pub.pem
openssl pkey -pubin -in example.com.pub.pem -noout -text | head -1
# Public-Key: (256 bit)
```

## Common misconceptions
- **The public key should be kept secret.** It is public by design; only the private key needs protection.
- **TLS encrypts traffic with the server's public key.** In TLS 1.3 the certificate key only signs; traffic keys come from an ephemeral (EC)DHE exchange.
- **A public key and a certificate are the same thing.** The certificate wraps the public key with identity information, validity dates and the CA's signature.

## Related terms

- [私钥](https://ssl.sh/zh/glossary/private-key/): 私钥是非对称密钥对中保密的那一半，TLS 服务器用它证明自己拥有证书里的那把公钥。
- [RSA](https://ssl.sh/zh/glossary/rsa/): RSA 是 1977 年提出的公钥算法，TLS 用它对证书和握手进行签名，在 TLS 1.3 之前还用它传输会话密钥。
- [ECDSA](https://ssl.sh/zh/glossary/ecdsa/): ECDSA 是基于椭圆曲线的数字签名算法，在 TLS 证书中作为 RSA 的替代方案，密钥和签名更小、签名运算更快。
- [X.509](https://ssl.sh/zh/glossary/x509/): X.509 是 ITU-T 制定的公钥证书标准格式，其互联网配置规范 RFC 5280 规定了 TLS 所用证书的结构和验证方法。
- [证书指纹](https://ssl.sh/zh/glossary/certificate-fingerprint/): 证书指纹是对证书 DER 编码计算出的哈希值（通常用 SHA-256），用来唯一标识一张证书，它本身并不存储在证书里。
- [证书锁定](https://ssl.sh/zh/glossary/certificate-pinning/): 证书锁定是客户端侧的一项检查：只有服务器证书链中包含事先配置好的特定证书或公钥时，客户端才接受这次连接。
- [数字签名](https://ssl.sh/zh/glossary/digital-signature/): 数字签名是用私钥对消息计算出的一个值，任何持有对应公钥的人都能验证它，从而确认消息来源和内容未被篡改。
