Pcornel
Security · Asymmetric Cryptography

Public Key

Cheat sheet · https://pcornel.dk/topic.php?topic=4701

Back to the Topic

Answer

A public key is the shareable half of a key pair, published in certificates or authorized_keys. Others use it to encrypt data for the owner or verify the owner's signatures.

Remember

  • Public keys can be shared freely.
  • Their authenticity must be verified.
  • Certificates bind keys to identities.

First checks

  • openssl pkey -in key.pem -pubout -out pub.pem — extract public key
  • ssh-keygen -y -f — /.ssh/id_ed25519~SSH public key
  • openssl x509 -in cert.pem -noout -pubkey — from certificate

Commands

openssl x509 -in cert.pem -pubkey -noout

Verify in this order

private key → public key → shared and bound to identity

Where it usually breaks

First mismatch in key/secret generation → storage/rotation → trust/certificate validation → protocol negotiation → cryptographic operation → peer/application verification; preserve identity/policy/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=4701

Confirmation

Confirm action

Continue?