Description |
This article describes how to use OpenSSL to identify if the corresponding Private key matches with the certificate. |
Scope | FortiGate. |
Solution |
This article assumes an installed version of the third-party program 'OpenSSL' is present.
Requirements:
This article will use the OpenSSL to compare the hash/modulus of the Certificate and the Private key.
First, install OpenSSL for windows.
To check if a certificate and private key match using OpenSSL, compare the modulus of the public key extracted from both the certificate and the private key. If the modulus values are identical, the certificate and private key match.
Have the certificate and the private key in the same directory as OpenSSL Install. Otherwise, specify the path of the certificate and private key while generating the hashes.
Steps:
openssl x509 -noout -modulus -in certificate.crt | openssl md5
Example:
C:\openssl\bin>openssl x509 -noout -modulus -in certificate.crt | openssl md5
Replace certificate.crt with the actual path to the certificate file.
openssl rsa -noout -modulus -in private.key | openssl md5
Example:
C:\openssl\bin>openssl rsa -noout -modulus -in private.key | openssl md5
Replace private.key with the actual path to the private key file.
Note: This method works for RSA keys. For ECDSA keys, It would use openssl ec instead of openssl rsa for extracting the modulus from the private key.
Example:
C:\openssl\bin>openssl ec -in ecdsa_private.key -pubout | openssl md5
C:\openssl\bin>openssl x509 -noout -pubkey -in fortinet.crt | openssl md5
Note that OpenSSL is not supported or endorsed by Fortinet. In this article, OpenSSL is used to generate the modulus of the certificate and the private key to confirm if it is a match. |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.