#!/bin/sh # Expiry date of a domain's TLS certificate command -v openssl > /dev/null 2>&1 || { echo "openssl not found" >&2; exit 1; } DOMAIN="example.com" raw_date="$(echo | openssl s_client -connect "$DOMAIN:443" -servername "$DOMAIN" 2>/dev/null | openssl x509 -noout -enddate | cut -d= -f2)" date -d "$raw_date" +%Y-%m-%d