Last active
March 7, 2024 20:29
-
-
Save thierrymarianne/a9c21ecf1f77db17fd113c0b854dd4eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function get_TLS_certificate_expiration_date_for_host() { | |
local host="${1}" | |
local port="${2}" | |
if [ -z "${host}" ]; | |
then | |
echo 'A non-empty host is required as first argument.' | |
return 1; | |
fi | |
if [ -z "${port}" ]; | |
then | |
port=443 | |
fi | |
local command='echo | openssl s_client -servername '"${host}"' -connect '"${host}"':'"${port}"' 2> /dev/null' | |
command="$command"' | openssl x509 -noout -enddate' | |
if [ ! -z "${DEBUG}" ]; | |
then | |
echo '=> About to execute "'$command'"' | |
fi | |
/bin/bash -c "${command}" | |
} | |
alias get-TLS-certificate-expiration-date-for-host='get_TLS_certificate_expiration_date_for_host' | |
## From the command-line | |
#$ get-TLS-certificate-expiration-date-for-host thierry.marianne.io | |
# | |
# Copyright (C) 2024 Thierry Marianne <[email protected]> -- assert_monitored_domains_are_available.sh | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as | |
# published by the Free Software Foundation, either version 3 of the | |
# License, or (at your option) any later version. | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see <https://www.gnu.org/licenses/>. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment