I'm using openssl to check if there is tlsv1.3 support or not over the list of domains. I've write the script but the script doesn't get stopped its waits for me to press CTRL D than it gives me a result. here is the scirpt
!/usr/bin/env bash
filename='domains.txt'
while read line;do
domain=$line
if openssl s_client -connect $domain:443 -tls1_3 2>/dev/null | grep -q 'Protocol : TLSv1.3'; then
echo "tls V 1.3 being used "
else
echo "tls v 1.3 not begin used"
fi
done <$filename
I've also used echo with openssl like this
echo "x" | openssl s_client -connect www.example.com:443 -tls1_3 2>/dev/null | grep 'Protocol : TLSv1.3'
NOTE: When i run the command on terminal for individual site i get the result without typing CRTL D but when i used it in script using loop and if statement its waits for me to press CTRL D. Its really strange.
I've also tried echo "q" | openssl command
CodePudding user response:
Do like:
echo Q | timeout 1 openssl s_client -connect www.example.com:443 -tls1_3 2>/dev/null
Passing Q
will make it quit fast, and when can't connect timeout
will make it quit.
CodePudding user response:
thanks this works for me. Actually, when I'm using grep it gives me a false result without grep it works perfectly.
#!/usr/bin/env bash
for i in `cat domain.txt`; do
echo $i
if echo Q | timeout 3 openssl s_client -connect $i:443 -tls1_3 2>/dev/null; then
echo "$i" "tlsv1.3 enabled" >>output.txt
else
echo "$i" "tlsv1.3 disabled" >>output.txt
fi
done