Skip to content

SSL:Correlate PEM and KEY Files

lbonanomi edited this page Mar 22, 2019 · 1 revision

Correlating PEMs and Keys

You should have labelled your SSL .pem and .key files, but you didn't. Associate them with the power of math! If the checksums align between a key and PEM, they are a pair.

for f in $(ls | egrep -i "pem|key"); 
do
    printf $(openssl rsa -modulus -noout -in "$f" 2>/dev/null | openssl md5 | awk '{ print $NF }')"\t$f\n";
    printf $(openssl x509 -modulus -noout -in "$f" 2>/dev/null | openssl md5 | awk '{ print $NF }')"\t$f\n"; 
done | sort -k1 | grep -vi \.csr
Clone this wiki locally