#!/bin/bash [ -z "${1}" ] && { echo "domain - not spicified"; exit 1; } now=$(date '+%s') expiration_date=$(date -d "$(openssl s_client -connect ${1}:443 < /dev/null 2>/dev/null| openssl x509 -noout -dates|grep 'notAfter'|awk -F '=' '{print $2}')" '+%s') echo $(( ( expiration_date - now )/(60*60*24) ))