#!/bin/bash set -e [[ -z $2 ]] && echo "usage: ${0##*/} [smtp]" && exit 1 host=$1 port=$2 [[ $3 = smtp ]] && smtp="-starttls smtp" || smtp="" [[ ! -x `which openssl` ]] && echo install openssl or libressl first && exit 1 openssl version echo Q | openssl s_client -servername $host -connect $host:$port $smtp 2>/dev/null | \ openssl x509 -noout -text | less # -showcerts