Last active
May 14, 2022 17:15
-
-
Save tcely/fde435325ccc855a0330 to your computer and use it in GitHub Desktop.
Check supported ciphers with bash and openssl s_client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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