Validate additional SAN
This commit is contained in:
parent
863a0e4d06
commit
19325ffb2a
@ -13,18 +13,19 @@ restart_containers(){
|
|||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
|
||||||
# Autodiscover and Autoconfig (Thunderbird)
|
|
||||||
declare -a SQL_DOMAIN_ARR
|
declare -a SQL_DOMAIN_ARR
|
||||||
declare -a DOMAIN_ARR
|
declare -a DOMAIN_ARR
|
||||||
declare -a DOMAIN_ARR
|
declare -a DOMAIN_ARR
|
||||||
|
declare -a ADDITIONAL_VALIDATED_SAN
|
||||||
|
IFS=' ' read -r -a ADDITIONAL_SAN_ARR <<< "${ADDITIONAL_SAN}"
|
||||||
|
IPV4=$(curl -4s https://mailcow.email/ip.php)
|
||||||
|
|
||||||
while read line; do
|
while read line; do
|
||||||
SQL_DOMAIN_ARR+=("${line}")
|
SQL_DOMAIN_ARR+=("${line}")
|
||||||
done < <(mysql -h mysql-mailcow -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain" -Bs)
|
done < <(mysql -h mysql-mailcow -u ${DBUSER} -p${DBPASS} ${DBNAME} -e "SELECT domain FROM domain" -Bs)
|
||||||
|
|
||||||
for SQL_DOMAIN in "${SQL_DOMAIN_ARR[@]}"; do
|
for SQL_DOMAIN in "${SQL_DOMAIN_ARR[@]}"; do
|
||||||
IPV4=$(curl -4s https://mailcow.email/ip.php)
|
A_CONFIG=$(dig A autoconfig.${SQL_DOMAIN} +short)
|
||||||
A_CONFIG=$(dig A autoconfig.${SQL_DOMAIN} +short @208.67.220.222)
|
|
||||||
if [[ ! -z ${A_CONFIG} ]]; then
|
if [[ ! -z ${A_CONFIG} ]]; then
|
||||||
echo "Found A record for autoconfig.${SQL_DOMAIN}: ${A_CONFIG}"
|
echo "Found A record for autoconfig.${SQL_DOMAIN}: ${A_CONFIG}"
|
||||||
if [[ ${IPV4} == ${A_CONFIG} ]]; then
|
if [[ ${IPV4} == ${A_CONFIG} ]]; then
|
||||||
@ -37,7 +38,7 @@ while true; do
|
|||||||
echo "No A record for autoconfig.${SQL_DOMAIN} found"
|
echo "No A record for autoconfig.${SQL_DOMAIN} found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
A_DISCOVER=$(dig A autodiscover.${SQL_DOMAIN} +short @208.67.220.222)
|
A_DISCOVER=$(dig A autodiscover.${SQL_DOMAIN} +short)
|
||||||
if [[ ! -z ${A_DISCOVER} ]]; then
|
if [[ ! -z ${A_DISCOVER} ]]; then
|
||||||
echo "Found A record for autodiscover.${SQL_DOMAIN}: ${A_CONFIG}"
|
echo "Found A record for autodiscover.${SQL_DOMAIN}: ${A_CONFIG}"
|
||||||
if [[ ${IPV4} == ${A_DISCOVER} ]]; then
|
if [[ ${IPV4} == ${A_DISCOVER} ]]; then
|
||||||
@ -51,12 +52,27 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for SAN in "${ADDITIONAL_SAN_ARR[@]}"; do
|
||||||
|
A_SAN=$(dig A ${SAN} +short)
|
||||||
|
if [[ ! -z ${A_SAN} ]]; then
|
||||||
|
echo "Found A record for ${SAN}: ${A_SAN}"
|
||||||
|
if [[ ${IPV4} == ${A_SAN} ]]; then
|
||||||
|
echo "Confirmed A record ${SAN}"
|
||||||
|
ADDITIONAL_VALIDATED_SAN+=("${SAN}")
|
||||||
|
else
|
||||||
|
echo "Cannot match Your IP against hostname ${SAN}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "No A record for ${SAN} found"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
acme-client \
|
acme-client \
|
||||||
-v -e -b -N -n \
|
-v -e -b -N -n \
|
||||||
-f ${ACME_BASE}/acme/private/account.key \
|
-f ${ACME_BASE}/acme/private/account.key \
|
||||||
-k ${ACME_BASE}/acme/private/privkey.pem \
|
-k ${ACME_BASE}/acme/private/privkey.pem \
|
||||||
-c ${ACME_BASE}/acme \
|
-c ${ACME_BASE}/acme \
|
||||||
${MAILCOW_HOSTNAME} ${CONFIG_DOMAINS[*]} ${ADDITIONAL_SAN}
|
${MAILCOW_HOSTNAME} ${CONFIG_DOMAINS[*]} ${ADDITIONAL_VALIDATED_SAN[*]}
|
||||||
|
|
||||||
case "$?" in
|
case "$?" in
|
||||||
0) # new certs
|
0) # new certs
|
||||||
|
Loading…
Reference in New Issue
Block a user