Fun hacks, WP plugins, photography, and PKI junk. Languishing since 2008.
Find A Matching Certificate And Key Pair
If you have a list of keys and SSL certs and don’t know which cert belongs with which key, here’s a script for you. It’s not efficient (nested for loop!), but it gets the job done quickly.1
#!/bin/bash for i in `ls *.key` do key_mod=`openssl rsa -noout -in $i -modulus` for j in `ls *.cer` do x509_mod=`openssl x509 -noout -in $j -modulus` if [ "$x509_mod" == "$key_mod" ]; then echo "$j matches $i" fi done done
- If bash allowed multidimensional or associative arrays this would be trivial to optimize. ↩
| Print article | This entry was posted by Paul Kehrer on November 8, 2009 at 9:49 pm, and is filed under Posts. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |