Skip to content

Instantly share code, notes, and snippets.

@KlausTrainer
Created March 30, 2013 21:15
Show Gist options
  • Save KlausTrainer/5278364 to your computer and use it in GitHub Desktop.
Save KlausTrainer/5278364 to your computer and use it in GitHub Desktop.
Get a list of a server's supported SSL/TLS ciphers. http://ubuntuforums.org/showthread.php?t=1909914
#!/bin/bash
if ! [ $1 ];
then
echo syntax: $0 host [-v]
exit
fi
if [ "$2" == "-v" ];
then
verbose=true
fi
# OpenSSL requires the port number.
SERVER=$1:443
DELAY=0
ciphers=`openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g'`
echo Obtaining cipher list from `openssl version`.
for cipherLine in `openssl ciphers -v | awk '{print $1,":: "$5}' | sed -e "s/ :: Enc=[^(]*(/,/" -e "s/)$//"`;
do
cipher=`echo $cipherLine | sed "s/,.*//"`
bits=`echo $cipherLine | sed "s/[^,]*,//"`
result=`echo -n | openssl s_client -cipher "$cipher" -connect $SERVER 2>&1`
if [[ "$result" =~ "Cipher is $cipher" ]] ; then
echo "$cipher ($bits bits)... YES"
else
if [[ $verbose == true ]] ; then
if [[ "$result" =~ "Cipher is (NONE)" ]] ; then
error=`echo -n $result | cut -d':' -f6`
echo "$cipher ($bits bits)... NO ($error)"
else
echo "$cipher ($bits bits)... UNKNOWN RESPONSE"
fi
fi
fi
sleep $DELAY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment