How to Check If an RSA Cert Matches an RSA Key

Problem: you find a key and a cert file on, and need to check if the cert matches the key.

Solution: Check the modulo (n=p*q) of both key and cert to see if they are equal.

$ openssl rsa -modulus -noout -in yourrsa.key
Modulus=C8BEE8B687CC...
$ openssl x509 -modulus -noout -in  yourrsa.crt 
Modulus=C8BEE8B687CC...

Version: tested with openssl 3.0.11 on devuan 5