How to determine if a private key belongs to a public certificate
This document (7015500) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Server 15
Situation
Determine key values mismatch of private and public keys.
Resolution
SSL Certificates have a key pair: a public and a private key. These keys work together to establish an encrypted connection. They are not interchangeable with other keys, thus it can be important to verify an existing public server certificate and a private key are a pair before attempting to use them for encrypting communication.
Follow the steps below in a terminal window to verify a public certificate and private key are a pair.
Those commands validate if the private key belongs to the public certificate:
- openssl x509 -noout -modulus -in <public.crt> | openssl md5 > /tmp/crt.pub
Note: Replace <public.crt> with the filename of the public certificate.
- openssl rsa -noout -modulus -in <private.key> | openssl md5 > /tmp/key.pub
Note: Replace <private.key> with the filename of the private key. Enter the password if prompted.
- diff /tmp/crt.pub /tmp/key.pub
Note: If nothing is printed to the console, they were found to be a pair. Any differences are printed to the console in detail.
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:7015500
- Creation Date: 08-Aug-2014
- Modified Date:24-Jul-2023
-
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com