Untitled
unknown
plain_text
2 years ago
872 B
9
Indexable
import subprocess
def get_modulus_md5(file, is_cert):
if is_cert:
cmd = ['openssl', 'x509', '-noout', '-modulus', '-in', file]
else:
cmd = ['openssl', 'rsa', '-noout', '-modulus', '-in', file]
result = subprocess.run(cmd, capture_output=True, text=True)
modulus = result.stdout
cmd = ['openssl', 'md5']
result = subprocess.run(cmd, input=modulus, capture_output=True, text=True)
md5 = result.stdout
return md5
# replace these with your actual file paths
certificate_file = '/path/to/certificate.pem'
private_key_file = '/path/to/private_key.pem'
cert_md5 = get_modulus_md5(certificate_file, True)
key_md5 = get_modulus_md5(private_key_file, False)
if cert_md5 == key_md5:
print('The certificate matches the private key.')
else:
print('The certificate does not match the private key.')
Editor is loading...