Skip to content

Instantly share code, notes, and snippets.

@webprofusion-chrisc
Last active May 8, 2024 08:21
Show Gist options
  • Save webprofusion-chrisc/b4db8104fde9c1ecb9fc3683384c3d5e to your computer and use it in GitHub Desktop.
Save webprofusion-chrisc/b4db8104fde9c1ecb9fc3683384c3d5e to your computer and use it in GitHub Desktop.
Checking a cert and private key match using OpenSSL, the right way

If you google how to validate a cert and private key match most examples are RSA specific and use modulus output.

Those examples look something like: openssl x509 -in cert.pem -noout -modulus | openssl sha1

Instead use the proper OpenSSL public key support:

  • Check public key of certificate: openssl x509 -noout -pubkey -in cert.pem
  • Check public key based on private key: openssl pkey -pubout -in key.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment