Skip to content

Instantly share code, notes, and snippets.

@tcely
Last active May 14, 2022 17:15
Show Gist options
  • Save tcely/fde435325ccc855a0330 to your computer and use it in GitHub Desktop.
Save tcely/fde435325ccc855a0330 to your computer and use it in GitHub Desktop.
Check supported ciphers with bash and openssl s_client
#!/bin/bash
host="${1:-127.0.0.1}"
port="${2:-443}"
ciphers='ALL:!eNULL'
printf 'Using openssl at: '
command -v openssl
openssl version -a
printf '\nCiphers selected by server at %s using TCP port %s:\n' "$host" "$port"
while : ; do
nextCipher="$(openssl s_client </dev/null 2>/dev/null -connect "${host}:${port}" -cipher "$ciphers" | awk '$1 == "Cipher" && $2 == ":" {print $3; if (tmpkey) {print tmpkey}} /^Server Temp Key:/ {tmpkey=$0}')"
[ -z "$nextCipher" ] && break || echo "${nextCipher/$'\n'/ # }"
ciphers="${ciphers}:-${nextCipher%%$'\n'*}";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment