Skip to content

Instantly share code, notes, and snippets.

@ilude
Created March 2, 2012 18:10
Show Gist options
  • Save ilude/1960125 to your computer and use it in GitHub Desktop.
Save ilude/1960125 to your computer and use it in GitHub Desktop.
Test https ssl ciphers
#!/bin/bash
# OpenSSL requires the port number.
SERVER=localhost:443
DELAY=1
echo -n Testing ssl2...
result=$(echo -n | openssl s_client -ssl2 -connect $SERVER 2>&1)
if [[ "$result" =~ "Cipher :" ]] ; then
echo supported. INSECURE!
else
echo no support, OK
fi
echo -n Testing SSL secure renegotiation...
echo -n "" | openssl s_client -connect $SERVER 2>&1 | grep 'Secure Renegotiation'
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" =~ "Cipher is " ]] ; then
echo YES
else
if [[ "$result" =~ ":error:" ]] ; then
error=`echo -n $result | cut -d':' -f6`
echo NO \($error\)
else
echo UNKNOWN RESPONSE
echo $result
fi
fi
sleep $DELAY
done
@pantras
Copy link

pantras commented Sep 5, 2019

I had to update this to work with OpenSSL 1.1.0g 2 Nov 2017 because it prints Cipher is (NONE), which is misleading the script.

- if [[ "$result" =~ "Cipher is " ]] ; then
+ if [[ "$result" =~ "Cipher is $cipher" ]] ; then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment