Skip to content

Instantly share code, notes, and snippets.

@commenthol
Created July 13, 2017 16:47
Show Gist options
  • Save commenthol/194ea40f6e3cabb458f73dc64fc46aac to your computer and use it in GitHub Desktop.
Save commenthol/194ea40f6e3cabb458f73dc64fc46aac to your computer and use it in GitHub Desktop.
Test Cipher Suites, find TLS Protocols
#!/usr/bin/env bash
#
# From https://superuser.com/questions/109213/how-do-i-list-the-ssl-tls-cipher-suites-a-particular-website-offers
#
# Find cipher suites a website offers
#
# Usage
#
# ./test-ciphers.sh google.com:443
SERVER=$1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
for cipher in ${ciphers[@]}
do
#echo -n Testing $cipher...
result=$(echo -n | openssl s_client -cipher "$cipher" -connect $SERVER 2>&1)
if [[ "$result" =~ ":error:" ]] ; then
error=$(echo -n $result | cut -d':' -f6)
echo -n Testing $cipher...
echo NO \($error\)
else
if [[ "$result" =~ "Cipher is ${cipher}" || "$result" =~ "Cipher :" ]] ; then
echo -n Testing $cipher...
echo YES
else
echo -n Testing $cipher...
echo UNKNOWN RESPONSE
echo $result
fi
fi
done
#!/usr/bin/env bash
#
# Find TLS Protocols
#
# Usage
# ./test-tls.sh google.com:443
#
SERVER=$1
protocols=(-ssl3 -tls1_2 -tls1_1 -tls1)
echo Using $(openssl version).
for proto in ${protocols[@]}
do
echo -n Testing $proto...
result=$(echo -n | openssl s_client -connect $SERVER $proto 2>&1)
if [[ "$result" =~ "no peer certificate available" ]] ; then
error=$(echo -n $result | cut -d':' -f6)
echo NO \($error\)
else
if [[ "$result" =~ "Cipher is ${cipher}" || "$result" =~ "Cipher :" ]] ; then
echo YES
else
echo UNKNOWN RESPONSE
echo $result
echo ----------------------------------------------------
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment