You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
939 B
61 lines
939 B
4 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
|
port=443
|
||
|
tlsVersion=1
|
||
|
host=""
|
||
|
|
||
|
die(){
|
||
|
echo "$@" >&2
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
print_help(){
|
||
|
echo "Attempts to connect using different tls versions"
|
||
|
echo ""
|
||
|
echo "tlsversionconnect [options] <host>"
|
||
|
echo ""
|
||
|
echo "-p | --port port number (default 443)"
|
||
|
echo "-v | --version tls version (default 1)"
|
||
|
}
|
||
|
|
||
|
while [ "$#" -gt 0 ]; do
|
||
|
case "$1" in
|
||
|
-p|--port)
|
||
|
port="$2"
|
||
|
shift; shift
|
||
|
;;
|
||
|
-v|--version)
|
||
|
case "$2" in
|
||
|
1|1.0|1-0|1_0)
|
||
|
tlsVersion="1"
|
||
|
;;
|
||
|
1.1|1-1|1_1)
|
||
|
tlsVersion="1_1"
|
||
|
;;
|
||
|
1.2|1-2|1_2)
|
||
|
tlsVersion="1_2"
|
||
|
;;
|
||
|
1.3|1-3|1_3)
|
||
|
tlsVersion="1_3"
|
||
|
;;
|
||
|
esac
|
||
|
shift; shift
|
||
|
;;
|
||
|
-h|--help)
|
||
|
print_help
|
||
|
exit 0
|
||
|
;;
|
||
|
*)
|
||
|
host="$1"
|
||
|
shift
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
if [ -z "$host" ]; then
|
||
|
die "No host provided"
|
||
|
fi
|
||
|
|
||
|
echo \$ openssl s_client "-tls${tlsVersion}" -connect "${host}:${port}"
|
||
|
echo "" | openssl s_client "-tls${tlsVersion}" -connect "${host}:${port}"
|