SUSE Support

Here When You Need Us

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 10
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Server 15

Situation

How to determine if private key belongs to public certificate or key.
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:
 

  1. openssl x509 -noout -modulus -in <public.crt> | openssl md5 > /tmp/crt.pub
    Note: Replace <public.crt> with the filename of the public certificate.
     
  2. 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.
     
  3. 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

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.