| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# example certificate_request_checker script |
| 4 |
|
| 5 |
# pull certreq from stdin to shell variable |
| 6 |
certreq=`openssl req -text` |
| 7 |
|
| 8 |
# check for blacklisted Debian keys |
| 9 |
blacklist=`ls /usr/local/openssl-blacklist/blacklist.RSA-*` |
| 10 |
tag=`echo "$certreq" | \ |
| 11 |
openssl req -noout -modulus|sha1sum|cut -d ' ' -f 1|cut -c21-41` |
| 12 |
if [ `cat $blacklist | grep -c $tag` -ne 0 ]; then |
| 13 |
echo "known weak Debian key in certificate request" 1>&2 |
| 14 |
exit 1 |
| 15 |
fi |
| 16 |
|
| 17 |
# check for weak exponents |
| 18 |
exponent=`echo "$certreq" | \ |
| 19 |
openssl req -noout -pubkey | \ |
| 20 |
openssl rsa -pubin -text -noout | \ |
| 21 |
grep Exponent | awk '{print $2}'` |
| 22 |
if [ "$exponent" -lt 65537 ]; then |
| 23 |
echo "weak exponent ($exponent < 65537) in certificate request" 1>&2 |
| 24 |
exit 1 |
| 25 |
fi |
| 26 |
|
| 27 |
# all done |
| 28 |
exit 0 |