Перейти к содержимому
ecdsa.com

Key, Certificate and CSR Matcher — сопоставление ключа, сертификата и CSR

Вставьте в каждое поле закрытый ключ, сертификат, CSR или открытый ключ — или несколько PEM-блоков в одно поле. Инструмент сравнивает открытые ключи и показывает, какие элементы относятся к одной паре ключей.

100 % локально — всё работает в браузере, ни на один сервер ничего не отправляется

Загрузка инструмента сопоставления…

Закрытый ключ читается в этом браузере только для того, чтобы вычислить его открытый ключ. Он не отправляется на сервер и никогда не попадает в ссылку для общего доступа.

When a key and a certificate do not match

A server can only use a certificate together with the private key whose public half is inside that certificate. Load any other key and the TLS library refuses to start: OpenSSL, nginx, Apache, Node.js and Python report key values mismatch, Go says tls: private key does not match public key. The usual causes are mundane — a certificate renewed from a CSR that was made with a new key on another machine, an old key file left in place after a re-key, a CA portal that issued the certificate for an older CSR, or the intermediate certificate installed where the server's own certificate belongs.

This tool answers the question directly. Paste a private key, a certificate, a CSR or a public key into each box — or a whole bundle into one box — and it shows which items belong to the same key pair.

How the comparison works

Every item is reduced to its public key, the SubjectPublicKeyInfo (SPKI) of RFC 5280 §4.1.2.7:

  • a certificate carries its SPKI directly, and so does a CSR (RFC 2986);
  • a public key is read as an SPKI (PUBLIC KEY) or as a PKCS #1 RSA PUBLIC KEY;
  • a private key — PKCS #8, PKCS #1 or SEC1, PEM or DER — yields its public key: the modulus and exponent of an RSA key, the curve point computed from an EC scalar, the public key of an Ed25519, Ed448 or ML-DSA key.

Items are then grouped by key identity: the modulus and exponent for RSA, the curve and point for EC keys, the raw key bytes otherwise. This is what the classic openssl x509 -noout -modulus | openssl md5 comparison approximates — but it works for every key type, not only RSA, and it is not fooled by different encodings of the same key: a compressed and an uncompressed EC point, or one RSA key written once as rsaEncryption and once with an RSASSA-PSS identifier, are recognised as the same key pair.

For each item the matcher also shows the SHA-256 of its SPKI, in base64 and in hex. The base64 form is the public-key pin used by Android, OkHttp and TrustKit (see the SPKI pin generator); the hex form is what OpenSSL prints with the commands listed under the result, so you can repeat the check on the server itself:

The same fingerprint from a key and a certificate
openssl pkey -in private.key -pubout -outform DER | openssl dgst -sha256
openssl x509 -in certificate.pem -noout -pubkey | openssl pkey -pubin -outform DER | openssl dgst -sha256

Two items of one key pair print the same value. One caveat: the SPKI hash covers the algorithm identifier too, so the RSA-PSS case above shows two different hashes for the same key — the grouping, which compares the key itself, is the answer to trust.

Reading the result

The headline says whether everything matches, whether only one item was found, or how many different keys the inputs contain. Each item is listed with its kind, where it came from, its subject and key type, and a "Key 1", "Key 2"… label: items with the same label share a key pair.

A full chain file is a common surprise. It holds the server certificate and one or more intermediate certificates, and each intermediate belongs to the CA's key pair, not to yours — so a chain pasted next to your key always shows several keys. What matters is that the first certificate, the server's own, is in the same group as the private key. When a certificate and a CSR share a key but name different subjects, the matcher notes it: that is normal when an order was renewed with the same key and different names.

Private keys that are encrypted with a passphrase cannot be read here — decrypt a copy locally first (openssl pkey -in key.pem -out plain.pem) — and OpenSSH private keys need converting to PKCS #8 (ssh-keygen -p -m PKCS8 -f keyfile); the matcher tells you which case you hit.

What happens to a private key

Nothing leaves your browser. The private key is parsed in the page only to compute its public key; the report contains public data alone. Share links are built from the certificates, CSRs and public keys: private key blocks are cut out of every box before the link is made, and the Share button tells you when it left something out. If you would rather not paste a key at all, paste its public half instead — openssl pkey -in private.key -pubout prints it — and the comparison is exactly the same.

To create a new key and CSR in the browser, use the CSR generator; to inspect a certificate field by field, the certificate decoder.