#!/bin/sh openssl=/usr/bin/openssl grep=/usr/bin/grep awk=/usr/bin/awk echo=/bin/echo sed=/usr/bin/sed host=$1 port=$2 protocols="ssl2 ssl3 tls1 tls1_1 tls1_2" for protocol in $protocols do $openssl s_client -host $host -port $port -starttls imap -$protocol /dev/null | $grep ^New, | $awk '{print $2}' | $grep -v NONE > /dev/null if [ $? -eq 0 ] then case $protocol in ssl2) supported_protocols="SSL 2.0" ;; ssl3) supported_protocols="$supported_protocols, SSL 3.0" ;; tls1) supported_protocols="$supported_protocols, TLS 1.0" ;; tls1_1) supported_protocols="$supported_protocols, TLS 1.1" ;; tls1_2) supported_protocols="$supported_protocols, TLS 1.2" ;; esac fi done $echo $supported_protocols | $sed 's/^[, ]*//' exit 0