Get Certificate Expiration Date in a Shell Script

openssl s_client -servername $SERVER -connect $SERVER:443 </dev/null 2>/dev/null | \
  openssl x509 -noout -enddate | \
  sed 's/notAfter=//' | \
  xargs -0 date +"%Y-%m-%d" -u -d | tr -d '\n'

Use your own input

If you have values you'd like to use instead of the provided variables, type or paste your data into the variable inputs below. If Javascript is enabled, your text will automatically be added to the command and you can click to copy.