OpenSSL
Generate a self-signed certificate without passphrase in one line
openssl req -nodes -new -x509 -keyout server.key -out server.cert -days 3650
Getting the expiration time of an SMTP certificate
SERVERNAME=mail.example.com
printf 'quit\n' | openssl s_client -connect $SERVERNAME:587 -starttls smtp | openssl x509 -enddate -noout