Informations :
Dates
- Publish : : Wednesday 28 june 2023
- Modification : Thursday 09 may 2024
- 1693 views
Share :
NdM : 2023/07/09 - Mise à jour (ajout d'information et 2 scripts en fin d'article).
NdM : 2023/08/08 - Modification du script pour vérfier la validité de nos certificats SSL et exemple de mise à jour des champs d'enregistrement TLSA (DANE).
NdM : 2023/09/20 : Modification des scripts "acme-certif-date_verification.bash" et "acme-certif-frontend.bash"
NdM : 2023/12/14 : Modification du script "acme-certif-date_verification.bash" pour qu'il "nsupdate" les nouvelles valeurs TLSA du protocole HTTPS sur un serveur DNS.
NdM : 2023/12/22 : Modification du script "acme-certif-date_verification.bash" pour qu'il "nsupdate" les nouvelles valeurs TLSA du protocole SMTPS sur un serveur DNS.
NdM : 2024/05/09 : Modification du script "acme-certif-date_verification.bash" pour qu'il "SCP" et UPDATE/DEPLOY le nouveau certificats Let's Encrypt dans Zimbra mail serveur.
Je vais vous expliquer comment créer des certificats SSL/TLS Let's Encrypt en utilisant votre serveur DNS pour créer/valider et mettre à jour vos certificats internationalement.
Let's Encrypt est une autorité de certification qui fournit des certificats gratuits X.509 pour le protocole cryptographique TLS au moyen d'un processus automatisé.
Pré-requis : un serveur DNS authoritaire que vous administrez ; où nous allons activer le moyen de faire des mise à jour dynamique (si cela n'est pas déjà fait).
- Une documentation que j'ai écris : Configuration BIND9 Masters et Slaves
- Je vais utiliser la commande
nsupdatepour mettre à jour dynamiquement mon server DNS, lors de la création et des mises à jours des certificats.
nsupdatepermet de mettre à jour des "zones" DNS sur votre serveur autoritaire.
- Je vais utiliser l'utilitaire acme.sh pour communiquer avec Let's Encrypt.
acme.shpermet de créer des certificats SSL/TLS, et permet de mettre à jour vos certificats sur l'AC (l'Authorité de Certifications) Let's Encrypt pour que vos certifats SSL/TLS restent valident dans le monde entier.
Installer acme.sh un des utilitaires de Let's Encrypt
Je choisis d'installer acme.sh sur mon container "web" (je vous dis pourquoi, bientôt).
Pour l'installation c'est simple :
Script avec 10 lignes
001root@web:~ # git clone https://github.com/acmesh-official/acme.sh.git002cd acme.sh003./acme.sh --install004--home ~/acme005--config-home ~/acme/data006--cert-home ~/acme/mycerts007--accountemail "admin@mydomain.tld"008--accountkey ~/acme/myaccount.key009--accountconf ~/acme/myaccount.conf010--useragent "Mozilla/5.0 (compatible; Linux 4.19.0-8-amd64; x86_64) MYACME.Bot/YOUR-CREW (20221002)."
Les options de configuration d'installation sous les suivantes :
--homeest un répertoire personnalisé dans lequel installer acme.sh. Par défaut, il s'installe dans~/.acme.sh--config-homeest un dossier inscriptible, acme.sh y écrira tous les fichiers (y compris cert/keys, configs). Par défaut, c'est dans--home--cert-homeest un répertoire personnalisé pour enregistrer les certificats que vous émettez. Par défaut, il est enregistré dans--config-home.--accountemailest l'e-mail utilisé pour enregistrer un compte sur Let's Encrypt, vous recevrez un e-mail d'avis de renouvellement ici.--accountkeyest le fichier qui enregistre la clé privée de votre compte. Par défaut, il est enregistré dans--config-home.--user-agentest la valeur d'en-tête de l'agent utilisateur utilisée pour envoyer à Let's Encrypt.--nocroninstalleracme.shsans cronjob
Qui me crée dans mon répertoire /root le répertoire acme/
Script avec 12 lignes
001root@web:~ # ls -la acme/002total 260003drwx------ 6 root root 4096 juin 10 00:20 .004drwx------ 15 root root 12288 juin 26 16:05 ..005-rwxr-xr-x 1 root root 220762 juin 10 00:20 acme.sh006-rw-r--r-- 1 root root 142 nov. 27 2022 acme.sh.env007drwx------ 26 root root 4096 juin 17 15:46 data008drwxr-xr-x 2 root root 4096 juin 10 00:20 deploy009drwxr-xr-x 2 root root 4096 juin 10 00:20 dnsapi010-rw-r--r-- 1 root root 591 juin 26 00:51 myaccount.conf011-rw------- 1 root root 1675 nov. 27 2022 myaccount.key012drwxr-xr-x 2 root root 4096 juin 10 00:20 notify
Ci-dessous le contenu du fichier /root/acme/myaccount.conf
Script avec 16 lignes
001LOG_FILE="/root/acme/data/acme.sh.log"002LOG_LEVEL=1003 004AUTO_UPGRADE='1'005 006#NO_TIMESTAMP=1007 008ACCOUNT_KEY_PATH='/root/acme/myaccount.key'009ACCOUNT_EMAIL='admin+acme@mydomain.tld'010UPGRADE_HASH='b7caf7a0165yuaeiyaeuicfksmlka06bb32025066d'011USER_AGENT='Mozilla/5.0 (compatible; Linux 4.19.0-8-amd64; x86_64) MYACME.Bot/ZW3B (20221127).'012SAVED_NSUPDATE_SERVER='dns.ipv10.net'013SAVED_NSUPDATE_SERVER_PORT=''014SAVED_NSUPDATE_KEY='/root/nsupdate/Knsupdate-key-zone.+157+09852.private'015SAVED_NSUPDATE_ZONE=''016USER_PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/local/openldap/bin'
Avant de pouvoir créer un certificat, il faut configurer "une" zone de notre serveur DNS pour qu'il accepte les mises à jour dynamique - si vous ne connaissez pas vous allez aimer.
J'ajoute la ligne de la tâche planifiée (que j'ai transformé -- j'ai ajouté "une attente (sleep) avec un nombre (-n1) aléatoire (shuffle) entre 0 et une heure (3600sec)" à minuit heure locale, pour ne pas surcharger les serveurs Let's Encrypt tous les jours à la même seconde).
Script avec 3 lignes
001root@web:~ # crontab -l002[....]00300 00 * * * sleep $(shuf -i 0-3600 -n1) ; "/root/acme"/acme.sh --cron --home "/root/acme" --config-home "/root/acme/data" > /dev/null
Configurer une zone DNS, nous disons "example.com" pour les mises à jour dynamique par nsupdate
Dans le fichier name.conf.local ajouter à une zone l'option allow-update avec la clef tsig :
Par exemple : /etc/bind/named.conf.local
Script avec 12 lignes
001[...]002zone "example.com" {003type master;004# file "/etc/bind/masters/example.com.hosts";005file "/etc/bind/masters/example.com.hosts.signed";006 007allow-transfer { key "ns-ldap"; };008allow-update { key "nsupdate-key-zone"; };009 010notify yes;011};012[...]
Pour créer la clef tsig de mise à jour dynamique :
Depuis le serveur DNS dans le répertoire correspondant à l'emplacement de clefs key-directory que nous avons configué dans les "options" du fichier /etc/bind/named.conf.options :
Script avec 1 ligne
001root@dns:/etc/bind/keys # tsig-keygen -a hmac-sha512 nsupdate-key-zone
Il faut passer les clefs à l'utilisateur "bind".
Qui nous créait 2 fichiers :
Script avec 3 lignes
001root@dns:/etc/bind/keys # ls -l Knsupdate-key-zone.+157+09852.*002-rw-r--r-- 1 bind bind 123 nov. 17 2022 Knsupdate-key-zone.+157+09852.key003-rw------- 1 bind bind 229 nov. 17 2022 Knsupdate-key-zone.+157+09852.private
Maintenant il faut envoyer sur le serveur Web la clef pour pouvoir utiliser nsupdate depuis notre serveur Web.
J'oubliais, il faut autoriser le serveur Web à faire des mises à jour. Pour cela, dans un des fichiers de "bind" ajouter :
Par exemple dans /etc/bind/named.conf :
Script avec 7 lignes
001[...]002# WEB.SERVER (IPv6)003server 2607:5300:60:9389:15:1:a:10 {004transfer-format many-answers;005keys { "nsupdate-key-zone"; };006};007[...]
Pour transférer la clef dans le répertoire nsupdate/ de l'utilisateur "root" du serveur "web" vous pouvez utiliser la commande :
Script avec 1 ligne
001root@dns:/etc/bind/keys # scp /etc/bind/keys/Knsupdate-key-zone.+157+09852.private root@web:/root/nsupdate/
Nous allons pouvoir créer et mettre à jour nos certificats SSL/TLS Let's Encrypt avec acme.sh.
Créons un certificat Let's Encrypt pour notre zone / nom de domaine "example.com"
Depuis le serveur Web, là où nous avons installer acme.sh, créons un certificat.
Script avec 1 ligne
001root@web:~ # acme.sh --install-cert --domain example.com
Ca va nous créait un répertoire ici :
Script avec 4 lignes
001root@web:~ # ls -l /root/acme/data/example.com002total 8003drwxr-xr-x 2 root root 4096 juin 17 15:45 backup004-rw-r--r-- 1 root root 98 juin 17 15:45 example.com.conf
Ensuite, vous pouvez envoyer la commande comme çà (nul besoin d'envoyer les variable d'environnement NSUPDATE_SERVER et NSUPDATE_KEY) :
Script avec 80 lignes
001root@web:~ # NSUPDATE_SERVER="dns.ipv10.net" NSUPDATE_KEY="/root/nsupdate/Knsupdate-key-zone.+157+09852.private" acme.sh --issue -k ec-384 -d example.com -d '*.example.com ' --dns dns_nsupdate --server letsencrypt002[dimanche 27 novembre 2022, 18:41:37 (UTC+0100)] Using CA: https://acme-v02.api.letsencrypt.org/directory003[dimanche 27 novembre 2022, 18:41:37 (UTC+0100)] Creating domain key004[dimanche 27 novembre 2022, 18:41:37 (UTC+0100)] The domain key is here: /root/acme/data/example.com_ecc/example.com.key005[dimanche 27 novembre 2022, 18:41:37 (UTC+0100)] Multi domain='DNS:example.com,DNS:*.example.com'006[dimanche 27 novembre 2022, 18:41:37 (UTC+0100)] Getting domain auth token for each domain007[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] Getting webroot for domain='example.com'008[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] Getting webroot for domain='*.example.com'009[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] Adding txt value: cFXIej611Rh8iar4hJiJfus85uHSk9FIhEWllDCrrQ4 for domain: _acme-challenge.example.com010[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] adding _acme-challenge.example.com. 60 in txt "cFXIej611Rh8iar4hJiJfus85uHSk9FIhEWllDCrrQ4"011[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] The txt record is added: Success.012[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] Adding txt value: C8vU4Sgg0UythPJfeudNr9dvEl8D6eULaBHDRgKHESs for domain: _acme-challenge.example.com013[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] adding _acme-challenge.example.com. 60 in txt "C8vU4Sgg0UythPJfeudNr9dvEl8D6eULaBHDRgKHESs"014[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] The txt record is added: Success.015[dimanche 27 novembre 2022, 18:41:39 (UTC+0100)] Let's check each DNS record now. Sleep 20 seconds first.016[dimanche 27 novembre 2022, 18:42:00 (UTC+0100)] You can use '--dnssleep' to disable public dns checks.017[dimanche 27 novembre 2022, 18:42:00 (UTC+0100)] See: https://github.com/acmesh-official/acme.sh/wiki/dnscheck018[dimanche 27 novembre 2022, 18:42:00 (UTC+0100)] Checking example.com for _acme-challenge.example.com019[dimanche 27 novembre 2022, 18:42:01 (UTC+0100)] Not valid yet, let's wait 10 seconds and check next one.020[dimanche 27 novembre 2022, 18:42:12 (UTC+0100)] Checking example.com for _acme-challenge.example.com021[dimanche 27 novembre 2022, 18:42:12 (UTC+0100)] Domain example.com '_acme-challenge.example.com' success.022[dimanche 27 novembre 2022, 18:42:12 (UTC+0100)] Let's wait 10 seconds and check again.023[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] You can use '--dnssleep' to disable public dns checks.024[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] See: https://github.com/acmesh-official/acme.sh/wiki/dnscheck025[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] Checking example.com for _acme-challenge.example.com026[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] Domain example.com '_acme-challenge.example.com' success.027[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] Checking example.com for _acme-challenge.example.com028[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] Already success, continue next one.029[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] All success, let's return030[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] Verifying: example.com031[dimanche 27 novembre 2022, 18:42:24 (UTC+0100)] Pending, The CA is processing your order, please just wait. (1/30)032[dimanche 27 novembre 2022, 18:42:27 (UTC+0100)] Success033[dimanche 27 novembre 2022, 18:42:27 (UTC+0100)] Verifying: *.example.com034[dimanche 27 novembre 2022, 18:42:28 (UTC+0100)] Pending, The CA is processing your order, please just wait. (1/30)035[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Success036[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Removing DNS records.037[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Removing txt: cFXIej611Rh8iar4hJiJfus85uHSk9FIhEWllDCrrQ4 for domain: _acme-challenge.example.com038[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] removing _acme-challenge.example.com. txt039[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Removed: Success040[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Removing txt: C8vU4Sgg0UythPJfeudNr9dvEl8D6eULaBHDRgKHESs for domain: _acme-challenge.example.com041[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] removing _acme-challenge.example.com. txt042[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Removed: Success043[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Verify finished, start to sign.044[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Lets finalize the order.045[dimanche 27 novembre 2022, 18:42:32 (UTC+0100)] Le_OrderFinalize='https://acme-v02.api.letsencrypt.org/acme/finalize/844254157/148100921877'046[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] Downloading cert.047[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] Le_LinkCert='https://acme-v02.api.letsencrypt.org/acme/cert/039018fe4ff377bae8ffa5414587248b87ba'048[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] Cert success.049-----BEGIN CERTIFICATE-----050MIIEcDCCA1igAwIBAgISA5AY/k/zd7ro/6VBRYcki4e6MA0GCSqGSIb3DQEBCwUA051MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD052EwJSMzAeFw0yMjExMjcxNjQyMzNaFw0yMzAyMjUxNjQyMzJaMBIxEDAOBgNVBAMT053B3p3M2IudHYwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATyBsggIW81ICHMZRSZC7+z054eT4vehWp+8/DjzzYVOXTbVXfoYT0OK7FG1bFe6w9K5RHjo6oAXDsaRYILUDpPxwd055Ds/EDBx4a0FLlLhF5TRak2E4J0yWWcjTTzHSSaJWR+OjggJMMIICSDAOBgNVHQ8B056Af8EBAMCB4AwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1UdEwEB057/wQCMAAwHQYDVR0OBBYEFN/cg8rD30RVvd5cFNjYTqnrvdBQMB8GA1UdIwQYMBaA058FBQusxe3WFbLrlAJQOYfr52LFMLGMFUGCCsGAQUFBwEBBEkwRzAhBggrBgEFBQcw059AYYVaHR0cDovL3IzLm8ubGVuY3Iub3JnMCIGCCsGAQUFBzAChhZodHRwOi8vcjMu060aS5sZW5jci5vcmcvMB0GA1UdEQQWMBSCCSouenczYi50doIHenczYi50djBMBgNV061HSAERTBDMAgGBmeBDAECATA3BgsrBgEEAYLfEwEBATAoMCYGCCsGAQUFBwIBFhpo062dHRwOi8vY3BzLmxldHNlbmNyeXB0Lm9yZzCCAQMGCisGAQQB1nkCBAIEgfQEgfEA0637wB2AHoyjFTYty22IOo44FIe6YQWcDIThU070ivBOlejUutSAAABhLou/8IAAAQD064AEcwRQIgBwly1igZHpDTzGGpd01WNVxrqRYH00LcCvLA7x4IXdgCIQDnkhdkMW+S065pbrbHQ4Uqv8pBrVXnL2nLgkyImUWGHU76AB1AK33vvp8/xDIi509nB4+GGq0Zyld066z7EMJMqFhjTr3IKKAAABhLou/9AAAAQDAEYwRAIgEMQsh2lYmTLkKpDDyEQuCnsO067nA6/vnZVgdJcDE74HkwCIF/rhY/n0ZH6LL4yICj63JZzdJThnIq9zNjj03PlhraL068MA0GCSqGSIkjldqdjql133qjdqljdlàç212dGGGxZGJXQ+sgKkxYBY5O2lxhvTgp069V9mOr0HABBYJomGmlJ3o9/BZ6aADnQ40W8B8xnh5PlaDi0rNQ3gBhwLn4tZB+NfK070KQDLpPIGqRrsdfACnkiu4GoiFkBBJY+HkgatAWdlRrlTlM8AkZNrX1kzg8u3jQY1071SVVJ8g4qjbYWdCaUe8r/EMILX9bL4LvNtvW4gvQsNWVF2E7GbzawK153j1aP8gLl072kCjTWyLOIWA1nhhoKKadcIYgmYG7GF3VMXceprrBPIMmRPRrCfRGErqVhxK3hvc80732uiyN3YDbpOHClnVe9PYjJZIVSswSXwYZKZkkRkAQKLgDTCs074-----END CERTIFICATE-----075[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] Your cert is in: /root/acme/data/example.com_ecc/example.com.cer076[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] Your cert key is in: /root/acme/data/example.com_ecc/example.com.key077[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] The intermediate CA cert is in: /root/acme/data/example.com_ecc/ca.cer078[dimanche 27 novembre 2022, 18:42:33 (UTC+0100)] And the full chain certs is there: /root/acme/data/example.com_ecc/fullchain.cer079Vous avez du nouveau courrier dans /var/mail/root080root@web:~ #
À ce moment là, nous avons un certificat pour notre nom de domaine "example.com" et tous ces sous domaines "*.example.com"
Ce n'est pas forcement nécessaire, vous pouvez créer un certificat en plus pour "ftp.example.com" ; à vous de voir - ce permet d'avoir un/des certificats pour chaque machine, type de service.
TODO Note de Moi-même : Il y a des "get options" à la commande acme.sh comme --reloadcmd et --renew-hook. À tester, pour mettre à jour les champs TLSA (DANE).
Créer un certificat pour un "alias de domaine"
Pour faire un certificat Let's Encrypt pour le domaine "domain.com" qui est un DNAME (alias de domaine) de "other_domain.com" la commande serait :
Script avec 1 ligne
001root@web:~ # acme.sh --issue -k ec-384 -d domain.com -d '*.domain.com' --domain-alias other_domain.com --dns dns_nsupdate --server letsencrypt
Pour faire un certificat Let's Encrypt pour le domaine "domain.com" et tous ses sous-domaine "*.domain.com" ainsi que "other_domain.com" et tous ses sous-domaine "*.other_domain.com" et que "other_domain.com" est un alias de nom de domaine de "domain.com" (--challenge-alias domain.com)
Script avec 1 ligne
001root@web:~ # acme.sh --issue -k ec-384 -d domain.com -d '*.domain.com' --challenge-alias domain.com -d other_domain.com -d '*.other_domain.com' --dns dns_nsupdate --server letsencrypt --force
Pour vous donner un exemple d'alias de domaine → lab3w.com est un alias de domaine de lab3w.fr :
Script avec 6 lignes
001root@web:~ # host www.lab3w.com002lab3w.com has DNAME record lab3w.fr.003www.lab3w.com is an alias for www.lab3w.fr.004www.lab3w.fr is an alias for web.lab3w.fr.005web.lab3w.fr has address 158.69.126.137006web.lab3w.fr has IPv6 address 2607:5300:60:9389:15:1:0:1
J'utilise l'algorithme de sécurité de courbes elliptiques (ec) d'une valeur de 384 bits.
Vous pouvez utiliser :
-k ec-256
Ou d'autres algorithme moins récents.
Configurer les certificats Let's Encrypt à votre serveur Web Apache :
Ajouter votre certificat SSL à votre site Web HTTPS "*.example.com:443"
Script avec 20 lignes
001<IfModule mod_ssl.c>002<VirtualHost [2607:5300:0060:9389:0015:0001:000a:0010]:443 10.101.150.10:443>003 004ServerName example.com005ServerAlias *.example.com006007SSLEngine On008 009# SSLProtocol -all +SSLv2010# SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP011# SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW012013SSLCertificateFile /root/acme/data/example.com_ecc/example.com.cer014SSLCertificateKeyFile /root/acme/data/example.com_ecc/example.com.key015SSLCACertificateFile /root/acme/data/example.com_ecc/ca.cer016017[...]018019</VirtualHost>020</IfModule>
SSL configuration serveur Web :
- Exemple d'intégration d'un certificat SSL sur des serveurs Web moz://a SSL Configuration Generator
Informations, scripts sur certificats SSL/TLS :
Je vous ajoute 2 scripts (vraiment à l'arache, çà peut aider) :
- Un pour tester la validité de certificats SSL, en ressortant la signature numérique du certificat et celle de la Ressource Records (l'enregistrement) TLSA (DANE).
- Et l'autre pour envoyer/déployer ses certificats SSL sur d'autres machines
1. Vérifier la date d'expiration d'un certificats SSL/TLS :
On créait un fichier : vim /root/acme-certif-date_verification.bash
Script avec 224 lignes
001#!/bin/bash002#-----------------------------------003# Checking certificates SSL date expiration004#-----------------------------------005# Author : O.Romain.Jaillet-ramey (orj AT lab3w DOT fr)006# Date created : 20221201007# Date modified : 20231222008#-----------------------------------009 010#-----------------------------------011# Config de la clef DNS pour l'update012key_file="/root/Kupdate-dd-zone.+157+09856.private"013maj_nsupdate=1014 015# Config Let's Encrypt dir016dir_certs="/root/acme/data/"017#dir_certs="/etc/ssl/letsencrypt/"018 019# Config Let's Encrypt check domains020domains="lab3w.fr zw3b.fr zw3b.tv zw3b.site zw3b.com zw3b.net zw3b.blog zw3b.eu ipv10.net mail.zw3b.eu"021#domains="lab3w.lan"022 023#----------------------------------024# ZIMBRA MAIL SERVER UPDATE CERTICATE025# 20240509026 027# Config private key SSH for update on zimbra mail server028ssh_public_key="/root/.ssh/id_ecdsa.pub"029zimbra_mail_server_addr="10.104.0.1"030zimbra_mail_server_user="root"031 032# Value to ssh-agent (for loggin automatic → https://howto.zw3b.fr/linux/reseaux/ssh-scp-par-certificats)033auth=`find /tmp -user $LOGNAME -type s -name "*agent*" -print 2>/dev/null`034SSH_AUTH_SOCK=$auth035export SSH_AUTH_SOCK036 037#-----------------------------------038 039#------------------------------------------------------------------------------------------------------040for domain in ${domains}; do041 042# expiryDate="$(echo $(date -d "$(echo | openssl s_client -servername ${domain} -connect ${domain}:443 -verify_quiet | openssl x509 -enddate -noout | awk -F= '{print $2}')"))"043expiryDate="$(echo $(date -d "$(echo | openssl x509 -in ${dir_certs}${domain}_ecc/${domain}.cer -enddate -noout | awk -F= '{print $2}')"))"044 045# expiryDays=$(( ($(date -d "$(echo | openssl s_client -servername ${domain} -connect ${domain}:443 -verify_quiet | openssl x509 -enddate -noout | awk -F= '{print $2}')" '+%s') - $(date '+%s')) / 86400 ))046expiryDays=$(( ($(date -d "$(echo | openssl x509 -in ${dir_certs}${domain}_ecc/${domain}.cer -enddate -noout | awk -F= '{print $2}')" '+%s') - $(date '+%s')) / 86400 ))047 048renewDay=$(($expiryDays - 30))049 050subjectAltName=$(echo | openssl x509 -noout -ext subjectAltName -in ${dir_certs}${domain}_ecc/${domain}.cer | grep DNS | tr -d [:blank:])051# subjectAltName=$(echo | openssl s_client -servername ${domain} -connect ${domain}:443 -verify_quiet | openssl x509 -noout -ext subjectAltName -noout | grep DNS | tr -d [:blank:])052 053signature_certif=$(openssl x509 -noout -fingerprint -sha256 < ${dir_certs}${domain}_ecc/${domain}.cer | tr -d : | cut -d"=" -f2)054signature_ondns=$(dig TLSA _443._tcp.${domain} @dns.google +short | awk {'print $4$5'})055 056old="$IFS"057IFS=","058tab=( $subjectAltName )059IFS="$old"060echo "#-----------------------------------"061echo "Domain : ${domain}"062echo "#----------"063echo ""064echo "Certificats SSL expiration date : ${expiryDate}"065echo "Certificats SSL expiration days : ${expiryDays}"066# echo "Subject Alt Names : ${subjectAltName}"067echo ""068echo "Subject Alt Names :"069echo " "070for (( i=0 ; i<${#tab[*]} ; i++ )) ; do071echo " +→ "${tab[$i]}072done073echo ""074echo "Certificat Signature check :"075echo " "076echo " +-" ${signature_certif} "→ Certificat signature"077if [ -n "${signature_ondns}" ]078then079echo " +-" ${signature_ondns} "→ Signature on DNS RR TLSA"080fi081if [ -z "${signature_ondns}" ]082then083echo " "084echo " +-→ NO DNS RR TLSA (DANE)"085fi086if [ "${signature_certif}" = "${signature_ondns}" ]087then088echo " "089echo " +-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK"090fi091 092if [ "${signature_certif}" != "${signature_ondns}" ] && [ -n "${signature_ondns}" ]093then094echo " "095echo " +-→ DNS RR TLSA (DANE) on Cerfificat Signature - NO OK"096echo " "097echo " +-→ Update your DNS RR TLSA (DANE) with "nsupdate" command"098echo " |"099echo " | ; example"100echo " | server dns.ipv10.net"101echo " | ;"102 103for (( i=0 ; i<${#tab[*]} ; i++ )) ; do104# ntab[$i]=$(echo ${tab[$i]} | awk 'BEGIN { FS = ":" }; { if($2 !~ /*/ ) print $2 }')105ntab[$i]=$(echo ${tab[$i]} | awk 'BEGIN { FS = ":" }; { print $2 }')106dtab[$i]=$(echo ${ntab[$i]} | awk 'BEGIN { FS="."} { print $(NF-1)"."$(NF); }')107ntab[$i]=$(echo ${ntab[$i]} | sed -e "s/*/www/g")108 109if [ "${ntab[$i]}" != "" ]110then111if [[ "${ntab[$i]}" =~ .*"${dtab[$i]}".* ]]; then112echo " | ; MAJ FOR WEB"113echo " | zone ${dtab[$i]}"114echo " | ; DANE RRset TLSA HTTP Secure"115echo " | update del _443._tcp.${ntab[$i]}. 3600 TLSA"116echo " | update add _443._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"117echo " | send"118echo " |"119fi120121if [[ "${domain}" == "mail.zw3b.eu" ]] && [[ "${ntab[$i]}" =~ .*"${dtab[$i]}".* ]]; then122if [[ "${ntab[$i]}" =~ .*"smtp".* ]]; then123echo " | ; MAJ FOR MX"124echo " | zone ${dtab[$i]}"125echo " | ; DANE RRset TLSA SMTP"126echo " | update del _25._tcp.${ntab[$i]}. 3600 TLSA"127echo " | update add _25._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"128echo " | ; DANE RRset TLSA SMTP Secure"129echo " | update del _465._tcp.${ntab[$i]}. 3600 TLSA"130echo " | update add _465._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"131echo " | ; DANE RRset TLSA SMTP Submission"132echo " | update del _587._tcp.${ntab[$i]}. 3600 TLSA"133echo " | update add _587._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"134echo " | send"135echo " |"136fi137fi138fi139done140echo " +------------------------------------"141echo ""142 143#--------------------------------144if [ "${maj_nsupdate}" -eq 1 ]145then146(147echo ";----------------------------------"148echo "; MAJ NSUPDATE...."149echo ";-------"150echo "server dns.ipv10.net"151echo ";-------"152echo ""153for (( i=0 ; i<${#tab[*]} ; i++ )) ; do154# ntab[$i]=$(echo ${tab[$i]} | awk 'BEGIN { FS = ":" }; { if($2 !~ /*/ ) print $2 }')155ntab[$i]=$(echo ${tab[$i]} | awk 'BEGIN { FS = ":" }; { print $2 }')156dtab[$i]=$(echo ${ntab[$i]} | awk 'BEGIN { FS="."} { print $(NF-1)"."$(NF); }')157ntab[$i]=$(echo ${ntab[$i]} | sed -e "s/*/www/g")158 159if [ "${ntab[$i]}" != "" ]160then161if [[ "${ntab[$i]}" =~ .*"${dtab[$i]}".* ]]; then162echo "; MAJ FOR WEB"163echo "zone ${dtab[$i]}"164echo "; DANE RRset TLSA HTTP Secure"165echo "update del _443._tcp.${ntab[$i]}. 3600 TLSA"166echo "update add _443._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"167echo "send"168echo ""169fi170 171if [[ "${domain}" == "mail.zw3b.eu" ]] && [[ "${ntab[$i]}" =~ .*"${dtab[$i]}".* ]]; then172if [[ "${ntab[$i]}" =~ .*"smtp".* ]]; then173echo "; MAJ FOR MX"174echo "zone ${dtab[$i]}"175echo "; DANE RRset TLSA SMTP"176echo "update del _25._tcp.${ntab[$i]}. 3600 TLSA"177echo "update add _25._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"178echo "; DANE RRset TLSA SMTP Secure"179echo "update del _465._tcp.${ntab[$i]}. 3600 TLSA"180echo "update add _465._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"181echo "; DANE RRset TLSA SMTP Submission"182echo "update del _587._tcp.${ntab[$i]}. 3600 TLSA"183echo "update add _587._tcp.${ntab[$i]}. 3600 TLSA 3 0 1 ${signature_certif}"184echo "send"185echo ""186fi187fi188fi189done190echo ";----------------------------------"191) | nsupdate -k ${key_file} -v192 193# ZIMBRA SCRIPT194# 20240509195if [ "${domain}" == "mail.zw3b.eu" ]; then196echo " +-→ Update Certificate on mail server "${domain}""197echo " |"198echo " "199echo " +-→ RSYNC"200rsync -av -e ssh -i ${ssh_public_key} /root/acme/data/${domain}_ecc/ ${zimbra_mail_server_user}@${zimbra_mail_server_addr}:/opt/zimbra/ssl/letsencrypt_ecc/201echo " +-→ Add Signature Certificat of ISRG Root X1 (Internet Security Research Group) to my certificate"202ssh ${zimbra_mail_server_user}@${zimbra_mail_server_addr} -i ${ssh_public_key} -x "cat /root/ISRG-X1.pem >> /opt/zimbra/ssl/letsencrypt_ecc/fullchain.cer ; sudo chown zimbra:zimbra /opt/zimbra/ssl/letsencrypt_ecc/${domain}.key"203echo " +-→ Verfication Certificate Chain by Zimbra command"204ssh ${zimbra_mail_server_user}@${zimbra_mail_server_addr} -i ${ssh_public_key} -x "sudo su - zimbra -c '/opt/zimbra/bin/zmcertmgr verifycrt comm /opt/zimbra/ssl/letsencrypt_ecc/${domain}.key /opt/zimbra/ssl/letsencrypt_ecc/${domain}.cer /opt/zimbra/ssl/letsencrypt_ecc/fullchain.cer'"205echo " +-→ Change old certicate to new certificate commercial"206ssh ${zimbra_mail_server_user}@${zimbra_mail_server_addr} -i ${ssh_public_key} -x "sudo cp /opt/zimbra/ssl/letsencrypt_ecc/${domain}.key /opt/zimbra/ssl/zimbra/commercial/commercial.key ; sudo chown zimbra:zimbra /opt/zimbra/ssl/zimbra/commercial/commercial.key"207echo " +-→ Finally deploy the new Let’s Encrypt SSL certificate."208ssh ${zimbra_mail_server_user}@${zimbra_mail_server_addr} -i ${ssh_public_key} -x "sudo su - zimbra -c '/opt/zimbra/bin/zmcertmgr deploycrt comm /opt/zimbra/ssl/letsencrypt_ecc/${domain}.cer /opt/zimbra/ssl/letsencrypt_ecc/fullchain.cer'"209echo " +-→ Restart Mail server Zimbra"210ssh ${zimbra_mail_server_user}@${zimbra_mail_server_addr} -i ${ssh_public_key} -x "/etc/init.d/zimbra restart"211fi212# ZIMBRA SCRIPT213214fi215#--------------------------------216 217fi218echo ""219done220 221echo "#-----------------------------------"222echo ""223 224exit 1
Donner les droits d'executer à l'utilisateur "chmod u+x /root/acme-certif-date_verification.bash" ;
puis lancer le script "/root/acme-certif-date_verification.bash".
Vous retournera quelque chose comme çà :
Script avec 571 lignes
001root@web:~ # /root/acme-certif-date_verification.bash002#-----------------------------------003Domain : lab3w.fr004#----------005 006Certificats SSL expiration date : samedi 23 septembre 2023, 23:51:07 (UTC+0200)007Certificats SSL expiration days : 46008 009Subject Alt Names :010011+→ DNS:*.lab3w.com012+→ DNS:*.lab3w.fr013+→ DNS:lab3w.com014+→ DNS:lab3w.fr015 016Certificat Signature check :017018+- ECFFB8AEA0FF53484F21294E4F69C39CF34F4D7390CAAC66B8C8B0A50657EA50 → Certificat signature019+- ECFFB8AEA0FF53484F21294E4F69C39CF34F4D7390CAAC66B8C8B0A50657EA50 → Signature on DNS RR TLSA020021+-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK022 023#-----------------------------------024Domain : zw3b.fr025#----------026 027Certificats SSL expiration date : vendredi 22 septembre 2023, 23:23:36 (UTC+0200)028Certificats SSL expiration days : 45029 030Subject Alt Names :031032+→ DNS:api.zw3b.fr033+→ DNS:howto.zw3b.fr034+→ DNS:mailing.zw3b.fr035+→ DNS:radio.zw3b.fr036+→ DNS:www.zw3b.fr037+→ DNS:zw3b.fr038 039Certificat Signature check :040041+- C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D → Certificat signature042+- C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D → Signature on DNS RR TLSA043044+-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK045 046#-----------------------------------047Domain : zw3b.tv048#----------049 050Certificats SSL expiration date : vendredi 22 septembre 2023, 23:24:59 (UTC+0200)051Certificats SSL expiration days : 45052 053Subject Alt Names :054055+→ DNS:www.zw3b.tv056+→ DNS:zw3b.tv057 058Certificat Signature check :059060+- 742D5E938E928F0E7F9A87811E0CFE1BE399005E2B2CAC1BBB42971E656C25A3 → Certificat signature061+- 742D5E938E928F0E7F9A87811E0CFE1BE399005E2B2CAC1BBB42971E656C25A3 → Signature on DNS RR TLSA062063+-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK064 065#-----------------------------------066Domain : zw3b.site067#----------068 069Certificats SSL expiration date : vendredi 20 octobre 2023, 23:33:51 (UTC+0200)070Certificats SSL expiration days : 73071 072Subject Alt Names :073074+→ DNS:*.zw3b.site075+→ DNS:zw3b.site076 077Certificat Signature check :078079+- C894DD1ACD81BF4613E69927FB0F7539018165182BA2C4B5587D33A8C9D1E411 → Certificat signature080+- C894DD1ACD81BF4613E69927FB0F7539018165182BA2C4B5587D33A8C9D1E411 → Signature on DNS RR TLSA081082+-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK083 084#-----------------------------------085Domain : zw3b.net086#----------087 088Certificats SSL expiration date : vendredi 22 septembre 2023, 23:24:08 (UTC+0200)089Certificats SSL expiration days : 45090 091Subject Alt Names :092093+→ DNS:www.zw3b.net094+→ DNS:zw3b.net095 096Certificat Signature check :097098+- 992DB6977A23A379BA0378335C26E0855CAA4DEF20D9BC986EE947C6FA9719C9 → Certificat signature099+- 992DB6977A23A379BA0378335C26E0855CAA4DEF20D9BC986EE947C6FA9719C9 → Signature on DNS RR TLSA100101+-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK102 103#-----------------------------------104Domain : zw3b.blog105#----------106 107Certificats SSL expiration date : samedi 23 septembre 2023, 23:51:42 (UTC+0200)108Certificats SSL expiration days : 46109 110Subject Alt Names :111112+→ DNS:*.zw3b.blog113+→ DNS:zw3b.blog114 115Certificat Signature check :116117+- 13B178DBE595C90AF7B461C115B5B2E323AC6403CACB2BA1F62345669DF47F25 → Certificat signature118+- 13B178DBE595C90AF7B461C115B5B2E323AC6403CACB2BA1F62345669DF47F25 → Signature on DNS RR TLSA119120+-→ DNS RR TLSA (DANE) on Cerfificat Signature - OK121 122#-----------------------------------123Domain : zw3b.eu124#----------125 126Certificats SSL expiration date : mercredi 20 mars 2024, 23:15:21 (UTC+0200)127Certificats SSL expiration days : 89128 129Subject Alt Names :130131+→ DNS:*.zw3b.eu132+→ DNS:zw3b.eu133 134Certificat Signature check :135136+- 76B2ABF86AD5D7002B03BAE2C7474E42E6ECA5DC4625BCABFBF9577165784274 → Certificat signature137+- 122DB6977A23A379BA0378335C26E0855CAA4DEF20D9BC986EE947C6FA9719D7 → Signature on DNS RR TLSA138139+-→ DNS RR TLSA (DANE) on Cerfificat Signature - NO OK140141+-→ Update your DNS RR TLSA (DANE) with "nsupdate" command142|143| ; example144| server dns.ipv10.net145| ;146| ; MAJ FOR WEB147| zone zw3b.eu148| ; DANE RRset TLSA HTTP Secure149| update del _443._tcp.www.zw3b.eu. 3600 TLSA150| update add _443._tcp.www.zw3b.eu. 3600 IN TLSA 3 0 1 76B2ABF86AD5D7002B03BAE2C7474E42E6ECA5DC4625BCABFBF9577165784274151| update del _443._tcp.zw3b.eu. 3600 TLSA152| update add _443._tcp.zw3b.eu. 3600 IN TLSA 3 0 1 76B2ABF86AD5D7002B03BAE2C7474E42E6ECA5DC4625BCABFBF9577165784274153| send154|155+------------------------------------156 157#-----------------------------------158Domain : ipv10.net159#----------160 161Certificats SSL expiration date : samedi 23 septembre 2023, 23:49:51 (UTC+0200)162Certificats SSL expiration days : 46163 164Subject Alt Names :165166+→ DNS:*.ipv01.net167+→ DNS:*.ipv10.net168+→ DNS:ipv01.net169+→ DNS:ipv10.net170 171Certificat Signature check :172173+- 924CACB8AB876888A3F07BDC9B6B6C39235502161991EECE5EC945174E91E07C → Certificat signature174175+-→ NO DNS RR TLSA (DANE) on Cerfificat Signature.176 177#-----------------------------------178Domain : mail.zw3b.eu179#----------180 181Certificats SSL expiration date : mercredi 20 mars 2024, 16:26:36 (UTC+0100)182Certificats SSL expiration days : 89183 184Subject Alt Names :185186+→ DNS:imap.zw3b.blog187+→ DNS:imap.zw3b.com188+→ DNS:imap.zw3b.eu189+→ DNS:imap.zw3b.fr190+→ DNS:imap.zw3b.net191+→ DNS:imap.zw3b.site192+→ DNS:imap.zw3b.tv193+→ DNS:mail.zw3b.blog194+→ DNS:mail.zw3b.com195+→ DNS:mail.zw3b.eu196+→ DNS:mail.zw3b.fr197+→ DNS:mail.zw3b.net198+→ DNS:mail.zw3b.site199+→ DNS:mail.zw3b.tv200+→ DNS:pop.zw3b.blog201+→ DNS:pop.zw3b.com202+→ DNS:pop.zw3b.eu203+→ DNS:pop.zw3b.fr204+→ DNS:pop.zw3b.net205+→ DNS:pop.zw3b.site206+→ DNS:pop.zw3b.tv207+→ DNS:smtp.zw3b.blog208+→ DNS:smtp.zw3b.com209+→ DNS:smtp.zw3b.eu210+→ DNS:smtp.zw3b.fr211+→ DNS:smtp.zw3b.net212+→ DNS:smtp.zw3b.site213+→ DNS:smtp.zw3b.tv214+→ DNS:webmail.zw3b.blog215+→ DNS:webmail.zw3b.com216+→ DNS:webmail.zw3b.eu217+→ DNS:webmail.zw3b.fr218+→ DNS:webmail.zw3b.net219+→ DNS:webmail.zw3b.site220+→ DNS:webmail.zw3b.tv221 222Certificat Signature check :223224+- 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F → Certificat signature225+- 738380ECBB58302D80948CAABBD0BBAD62A47F21BB5E29EEECD1E50354491078 → Signature on DNS RR TLSA226227+-→ DNS RR TLSA (DANE) on Cerfificat Signature - NO OK228229+-→ Update your DNS RR TLSA (DANE) with "nsupdate" command230|231| ; example232| server dns.ipv10.net233| ;234| ; MAJ FOR WEB235| zone zw3b.blog236| ; DANE RRset TLSA HTTP Secure237| update del _443._tcp.imap.zw3b.blog. 3600 TLSA238| update add _443._tcp.imap.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F239| send240|241| ; MAJ FOR WEB242| zone zw3b.com243| ; DANE RRset TLSA HTTP Secure244| update del _443._tcp.imap.zw3b.com. 3600 TLSA245| update add _443._tcp.imap.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F246| send247|248| ; MAJ FOR WEB249| zone zw3b.eu250| ; DANE RRset TLSA HTTP Secure251| update del _443._tcp.imap.zw3b.eu. 3600 TLSA252| update add _443._tcp.imap.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F253| send254|255| ; MAJ FOR WEB256| zone zw3b.fr257| ; DANE RRset TLSA HTTP Secure258| update del _443._tcp.imap.zw3b.fr. 3600 TLSA259| update add _443._tcp.imap.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F260| send261|262| ; MAJ FOR WEB263| zone zw3b.net264| ; DANE RRset TLSA HTTP Secure265| update del _443._tcp.imap.zw3b.net. 3600 TLSA266| update add _443._tcp.imap.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F267| send268|269| ; MAJ FOR WEB270| zone zw3b.site271| ; DANE RRset TLSA HTTP Secure272| update del _443._tcp.imap.zw3b.site. 3600 TLSA273| update add _443._tcp.imap.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F274| send275|276| ; MAJ FOR WEB277| zone zw3b.tv278| ; DANE RRset TLSA HTTP Secure279| update del _443._tcp.imap.zw3b.tv. 3600 TLSA280| update add _443._tcp.imap.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F281| send282|283| ; MAJ FOR WEB284| zone zw3b.blog285| ; DANE RRset TLSA HTTP Secure286| update del _443._tcp.mail.zw3b.blog. 3600 TLSA287| update add _443._tcp.mail.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F288| send289|290| ; MAJ FOR WEB291| zone zw3b.com292| ; DANE RRset TLSA HTTP Secure293| update del _443._tcp.mail.zw3b.com. 3600 TLSA294| update add _443._tcp.mail.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F295| send296|297| ; MAJ FOR WEB298| zone zw3b.eu299| ; DANE RRset TLSA HTTP Secure300| update del _443._tcp.mail.zw3b.eu. 3600 TLSA301| update add _443._tcp.mail.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F302| send303|304| ; MAJ FOR WEB305| zone zw3b.fr306| ; DANE RRset TLSA HTTP Secure307| update del _443._tcp.mail.zw3b.fr. 3600 TLSA308| update add _443._tcp.mail.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F309| send310|311| ; MAJ FOR WEB312| zone zw3b.net313| ; DANE RRset TLSA HTTP Secure314| update del _443._tcp.mail.zw3b.net. 3600 TLSA315| update add _443._tcp.mail.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F316| send317|318| ; MAJ FOR WEB319| zone zw3b.site320| ; DANE RRset TLSA HTTP Secure321| update del _443._tcp.mail.zw3b.site. 3600 TLSA322| update add _443._tcp.mail.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F323| send324|325| ; MAJ FOR WEB326| zone zw3b.tv327| ; DANE RRset TLSA HTTP Secure328| update del _443._tcp.mail.zw3b.tv. 3600 TLSA329| update add _443._tcp.mail.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F330| send331|332| ; MAJ FOR WEB333| zone zw3b.blog334| ; DANE RRset TLSA HTTP Secure335| update del _443._tcp.pop.zw3b.blog. 3600 TLSA336| update add _443._tcp.pop.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F337| send338|339| ; MAJ FOR WEB340| zone zw3b.com341| ; DANE RRset TLSA HTTP Secure342| update del _443._tcp.pop.zw3b.com. 3600 TLSA343| update add _443._tcp.pop.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F344| send345|346| ; MAJ FOR WEB347| zone zw3b.eu348| ; DANE RRset TLSA HTTP Secure349| update del _443._tcp.pop.zw3b.eu. 3600 TLSA350| update add _443._tcp.pop.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F351| send352|353| ; MAJ FOR WEB354| zone zw3b.fr355| ; DANE RRset TLSA HTTP Secure356| update del _443._tcp.pop.zw3b.fr. 3600 TLSA357| update add _443._tcp.pop.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F358| send359|360| ; MAJ FOR WEB361| zone zw3b.net362| ; DANE RRset TLSA HTTP Secure363| update del _443._tcp.pop.zw3b.net. 3600 TLSA364| update add _443._tcp.pop.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F365| send366|367| ; MAJ FOR WEB368| zone zw3b.site369| ; DANE RRset TLSA HTTP Secure370| update del _443._tcp.pop.zw3b.site. 3600 TLSA371| update add _443._tcp.pop.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F372| send373|374| ; MAJ FOR WEB375| zone zw3b.tv376| ; DANE RRset TLSA HTTP Secure377| update del _443._tcp.pop.zw3b.tv. 3600 TLSA378| update add _443._tcp.pop.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F379| send380|381| ; MAJ FOR WEB382| zone zw3b.blog383| ; DANE RRset TLSA HTTP Secure384| update del _443._tcp.smtp.zw3b.blog. 3600 TLSA385| update add _443._tcp.smtp.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F386| send387|388| ; MAJ FOR MX389| zone zw3b.blog390| ; DANE RRset TLSA SMTP391| update del _25._tcp.smtp.zw3b.blog. 3600 TLSA392| update add _25._tcp.smtp.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F393| ; DANE RRset TLSA SMTP Secure394| update del _465._tcp.smtp.zw3b.blog. 3600 TLSA395| update add _465._tcp.smtp.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F396| ; DANE RRset TLSA SMTP Submission397| update del _587._tcp.smtp.zw3b.blog. 3600 TLSA398| update add _587._tcp.smtp.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F399| send400|401| ; MAJ FOR WEB402| zone zw3b.com403| ; DANE RRset TLSA HTTP Secure404| update del _443._tcp.smtp.zw3b.com. 3600 TLSA405| update add _443._tcp.smtp.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F406| send407|408| ; MAJ FOR MX409| zone zw3b.com410| ; DANE RRset TLSA SMTP411| update del _25._tcp.smtp.zw3b.com. 3600 TLSA412| update add _25._tcp.smtp.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F413| ; DANE RRset TLSA SMTP Secure414| update del _465._tcp.smtp.zw3b.com. 3600 TLSA415| update add _465._tcp.smtp.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F416| ; DANE RRset TLSA SMTP Submission417| update del _587._tcp.smtp.zw3b.com. 3600 TLSA418| update add _587._tcp.smtp.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F419| send420|421| ; MAJ FOR WEB422| zone zw3b.eu423| ; DANE RRset TLSA HTTP Secure424| update del _443._tcp.smtp.zw3b.eu. 3600 TLSA425| update add _443._tcp.smtp.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F426| send427|428| ; MAJ FOR MX429| zone zw3b.eu430| ; DANE RRset TLSA SMTP431| update del _25._tcp.smtp.zw3b.eu. 3600 TLSA432| update add _25._tcp.smtp.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F433| ; DANE RRset TLSA SMTP Secure434| update del _465._tcp.smtp.zw3b.eu. 3600 TLSA435| update add _465._tcp.smtp.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F436| ; DANE RRset TLSA SMTP Submission437| update del _587._tcp.smtp.zw3b.eu. 3600 TLSA438| update add _587._tcp.smtp.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F439| send440|441| ; MAJ FOR WEB442| zone zw3b.fr443| ; DANE RRset TLSA HTTP Secure444| update del _443._tcp.smtp.zw3b.fr. 3600 TLSA445| update add _443._tcp.smtp.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F446| send447|448| ; MAJ FOR MX449| zone zw3b.fr450| ; DANE RRset TLSA SMTP451| update del _25._tcp.smtp.zw3b.fr. 3600 TLSA452| update add _25._tcp.smtp.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F453| ; DANE RRset TLSA SMTP Secure454| update del _465._tcp.smtp.zw3b.fr. 3600 TLSA455| update add _465._tcp.smtp.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F456| ; DANE RRset TLSA SMTP Submission457| update del _587._tcp.smtp.zw3b.fr. 3600 TLSA458| update add _587._tcp.smtp.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F459| send460|461| ; MAJ FOR WEB462| zone zw3b.net463| ; DANE RRset TLSA HTTP Secure464| update del _443._tcp.smtp.zw3b.net. 3600 TLSA465| update add _443._tcp.smtp.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F466| send467|468| ; MAJ FOR MX469| zone zw3b.net470| ; DANE RRset TLSA SMTP471| update del _25._tcp.smtp.zw3b.net. 3600 TLSA472| update add _25._tcp.smtp.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F473| ; DANE RRset TLSA SMTP Secure474| update del _465._tcp.smtp.zw3b.net. 3600 TLSA475| update add _465._tcp.smtp.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F476| ; DANE RRset TLSA SMTP Submission477| update del _587._tcp.smtp.zw3b.net. 3600 TLSA478| update add _587._tcp.smtp.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F479| send480|481| ; MAJ FOR WEB482| zone zw3b.site483| ; DANE RRset TLSA HTTP Secure484| update del _443._tcp.smtp.zw3b.site. 3600 TLSA485| update add _443._tcp.smtp.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F486| send487|488| ; MAJ FOR MX489| zone zw3b.site490| ; DANE RRset TLSA SMTP491| update del _25._tcp.smtp.zw3b.site. 3600 TLSA492| update add _25._tcp.smtp.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F493| ; DANE RRset TLSA SMTP Secure494| update del _465._tcp.smtp.zw3b.site. 3600 TLSA495| update add _465._tcp.smtp.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F496| ; DANE RRset TLSA SMTP Submission497| update del _587._tcp.smtp.zw3b.site. 3600 TLSA498| update add _587._tcp.smtp.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F499| send500|501| ; MAJ FOR WEB502| zone zw3b.tv503| ; DANE RRset TLSA HTTP Secure504| update del _443._tcp.smtp.zw3b.tv. 3600 TLSA505| update add _443._tcp.smtp.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F506| send507|508| ; MAJ FOR MX509| zone zw3b.tv510| ; DANE RRset TLSA SMTP511| update del _25._tcp.smtp.zw3b.tv. 3600 TLSA512| update add _25._tcp.smtp.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F513| ; DANE RRset TLSA SMTP Secure514| update del _465._tcp.smtp.zw3b.tv. 3600 TLSA515| update add _465._tcp.smtp.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F516| ; DANE RRset TLSA SMTP Submission517| update del _587._tcp.smtp.zw3b.tv. 3600 TLSA518| update add _587._tcp.smtp.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F519| send520|521| ; MAJ FOR WEB522| zone zw3b.blog523| ; DANE RRset TLSA HTTP Secure524| update del _443._tcp.webmail.zw3b.blog. 3600 TLSA525| update add _443._tcp.webmail.zw3b.blog. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F526| send527|528| ; MAJ FOR WEB529| zone zw3b.com530| ; DANE RRset TLSA HTTP Secure531| update del _443._tcp.webmail.zw3b.com. 3600 TLSA532| update add _443._tcp.webmail.zw3b.com. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F533| send534|535| ; MAJ FOR WEB536| zone zw3b.eu537| ; DANE RRset TLSA HTTP Secure538| update del _443._tcp.webmail.zw3b.eu. 3600 TLSA539| update add _443._tcp.webmail.zw3b.eu. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F540| send541|542| ; MAJ FOR WEB543| zone zw3b.fr544| ; DANE RRset TLSA HTTP Secure545| update del _443._tcp.webmail.zw3b.fr. 3600 TLSA546| update add _443._tcp.webmail.zw3b.fr. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F547| send548|549| ; MAJ FOR WEB550| zone zw3b.net551| ; DANE RRset TLSA HTTP Secure552| update del _443._tcp.webmail.zw3b.net. 3600 TLSA553| update add _443._tcp.webmail.zw3b.net. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F554| send555|556| ; MAJ FOR WEB557| zone zw3b.site558| ; DANE RRset TLSA HTTP Secure559| update del _443._tcp.webmail.zw3b.site. 3600 TLSA560| update add _443._tcp.webmail.zw3b.site. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F561| send562|563| ; MAJ FOR WEB564| zone zw3b.tv565| ; DANE RRset TLSA HTTP Secure566| update del _443._tcp.webmail.zw3b.tv. 3600 TLSA567| update add _443._tcp.webmail.zw3b.tv. 3600 TLSA 3 0 1 6A42E98D3EADBB58C37A4127CEF3BB8BD004AC8DA39EE14F46549E52C75F1C4F568| send569|570+------------------------------------571
C'est juste pour information (on n'a pas besoin forcement de ce script), çà peut nous servir. Note de Moi-même 2023/12/14 : C'était avant çà.
Note de Moi-même 2023/12/14 : J'ai ajouté la commande nsupdate (ligne 123 (101-127)) au script pour qu'il mette à jour les RR TLSA HTTPs sur le serveur DNS par nsupdate, si le certificat TLS Let's Encrypt change.
Note de Moi-même 2023/12/22 : J'ai ajouté la commande nsupdate au script pour qu'il mette à jour les RR TLSA SMTPs sur le serveur DNS par nsupdate, si le certificat TLS Let's Encrypt change.
Note de Moi-même 2023/12/25 : J'ai remarqué un truc "embêtant" ; sur les certificats en domaines wildcard, dans le script ci-dessus je prend en compte "domain.tld" et "www.domain.tld" et met à jour les champs TLSA ; mais donc, vu que c'est un wilcard je peut, donc signer DANE pour "admin.domain.tld" ou "sub.domain.tld" mais -- comment le savoir automatiquement -- il faut mettre à jour manuellement - Une autre solution, serait de faire d'autres certificats gratuit Let's Encrypt -- bien précis pour "admin" et ne pas utiliser le wilcard -- selon sa stratégie de sécurité ;) vous comprennez.
J'ai écris ce commentaire aujourd'hui sur Debian-FR pour "mieux" ré-écrire une de mes ligne.
Un exemple de mise a jour dynamique par « nsupdate » avec retour d'erreur ici.
Vous remarquerez que je vous parle des RR (Ressources Recors DNS) TLSA du protocole/mécanisme DANE (DNS - based Authentication of Named Entities) qui s'appuie sur le DNS pour authentifier des entités applicatives.
Par exemple pour les applications Web, vous pouvez utiliser "DNSSEC/DANE Validator" ; plugin Firefox qui vous permet de vérifier l'existence et la validité des enregistrements DNSSEC et TLSA liés aux noms de domaine.
Donc, normalement si vous avez suivis la procédure du dessus, acme.sh [...] --dns dns_nsupdate met à jour nos certificats SSL/TLS Let's Encrypt tous les 60 jours, 30 jours avant l'expiration (le certificat en valide 90 jours) (AUTO_UPGRADE='1' dans /root/acme/myaccount.conf).
Par contre, si vous avez besoin de déployer vos certificats SSL/TLS sur vos proxy, load balancer frontaux, clusters ou autres serveurs (HTTP, FTP etc.), ci-dessous un exemple.
2. Déployer vos certificats SSL/TLS sur d'autres serveurs :
Si vous avez besoin d'utiliser vos certificats sur d'autres machines.
Ci-dessous un script RSYNC pour envoyer vos certificats sur d'autres machines serveurs.
On créait un fichier : root@web:~ # vim /root/acme-certif-frontend.bash
Script avec 204 lignes
001#!/bin/bash002#-----------------------------------003# RSYNC script for tranfert SSL/TLS certificats files modified on others servers004#-----------------------------------005# Author : O.Romain.Jaillet-ramey (orj AT lab3w DOT fr)006# Date created : 20221201007# Date modified : 20230920008#-----------------------------------009 010#------------------------------------------------------------------------------------------------------011# Authentification par certicats (sans humain)012#-----013auth=`find /tmp -user $LOGNAME -type s -name "*agent*" -print 2>/dev/null`014SSH_AUTH_SOCK=$auth015export SSH_AUTH_SOCK016#------------------------------------------------------------------------------------------------------017 018#------------------------------------------------------------------------------------------------------019# Config020#-----021 022dir="/root/acme/data/"023#files_extension=".cer .key"024 025#------------------------------------------------------------------------------------------------------026# Files/Dir of certicats Domains to check with rsync027# ${dir}${domain}_ecc/028#-----029 030domains="lab3w.fr zw3b.fr zw3b.tv zw3b.site zw3b.net zw3b.blog zw3b.eu ipv10.net"031#domains="lab3w.lan"032 033#------------------------------------------------------------------------------------------------------034# Remote servers on which SSL certificates are needed035#-----036rservers="lb1.lab3w.lan lb2.lab3w.lan server.lab3w.com"037 038rdir="/etc/ssl/letsencrypt/"039ruser="root"040rkey=".ssh/id_ecdsa"041rport="22"042 043#------------------------------------------------------------------------------------------------------044# texts045#-----046 047text_file=()048text_file_ca=()049text_server=()050 051#------------------------------------------------------------------------------------------------------052# script053#-----054 055for rserver in ${rservers}; do056 057text_status=()058text_status_ca=()059text_domain=()060 061text_files=()062 063text_server=("${rserver}")064 065#------------------------------------------------------------------------------------------------------066# script authenfication067#-----068 069if ! ssh -p ${rport} -i ${rkey} ${ruser}@${rserver} "test pwd"; then070echo "Authentication failed !"071echo "Exit !"072exit 2073fi074 075#------------------------------------------------------------------------------------------------------076 077echo "#------------------------------------------------"078echo "SERVER : ${rserver}"079echo ""080 081#------------------------------------------------------------------------------------------------------082# script RSYNC083#-----084 085for domain in ${domains}; do086 087text_files=("${domain}")088 089if ! ssh -p ${rport} -i ${rkey} ${ruser}@${rserver} "test -x ${rdir}${domain}_ecc"; then090# echo "The remote directory "${rdir}${domain}_ecc" do not exist"091# echo "Create directory"092ssh -p ${rport} -i ${rkey} ${ruser}@${rserver} "mkdir -p ${rdir}${domain}_ecc"093 094if ! ssh -p ${rport} -i ${rkey} ${ruser}@${rserver} "test -x ${rdir}${domain}_ecc"; then095# echo "The remote directory "${rdir}${domain}_ecc" could not be created or has bad permissions."096# echo "Exit !"097exit 2098fi099 100# echo "Remote directory "${rdir}${domain}_ecc" OK !"101# echo ""102fi103 104# for ext in ${files_extension}; do105# output=$(rsync -a --info=NAME -e "ssh -i ${rkey}" ${dir}${domain}_ecc/${domain}${ext} ${ruser}@${rserver}:${rdir}${domain}_ecc/${domain}${ext})106output=$(rsync -a --info=NAME -e "ssh -i ${rkey}" ${dir}${domain}_ecc/ ${ruser}@${rserver}:${rdir}${domain}_ecc/)107if [ "output_${output}" = "output_" ]; then108text_status+=( "$(printf "%dn" $?)" )109text_domain+=( "${domain}" )110text_file+=( "${dir}${domain}_ecc/${output}" )111 112else113text_status+=(150)114text_domain+=( "${domain}" )115text_file+=( "${dir}${domain}_ecc/${output}" )116 117# text_files+=( "${domain}", "${dir}${domain}_ecc/${output}" )118 119fi120# rsync -a -e "ssh -i ${rkey}" ${dir}${domain}_ecc/ca.cer ${ruser}@${rserver}:${rdir}${domain}_ecc/ca.cer121# status_ca+=( "$(printf "%dn" $?)" )122# done123done # files124 125 126#done # rservers127 128#------------------------------------------------------------------------------------------------------129# Restart servers130#----131 132restart_server=0133 134msg=""135i=0136for code in "${text_status[@]}"; do137 138# msg+="# MSG $i : ${file_cert[$i]}n"139 140# echo "Code : ${code}"141if [ ${code} -eq 150 ]; then142 143msg+="#------------------------n"144msg+="# Server : ${text_server}n"145msg+="# Domain : ${text_domain[$i]}n"146msg+="# Files : ${text_file[$i]} is modified (status : ${text_status[$i]})n"147 148# for file in "${text_files[${text_domain[$i]}]}"; do149# msg+="# File : ${file} is modifiedn"150# done151 152msg+="#------------------------n"153 154restart_server=1155fi156 157i=$((${i} + 1))158done159 160if [ "_$msg" != "_" ]; then161echo -e $msg162fi163 164 165if [ ${restart_server} -eq 1 ]; then166 167for code in "${text_server[@]}"; do168 169# nodes servers170ssh -p ${rport} -i ${rkey} ${ruser}@${rserver} "/etc/init.d/apache2 reload"171 172echo "#--→ Server Apache ${rserver} reloading"173 174done175 176else177echo "#--→ Server Apache ${rserver} do not reloading (no update certificat)"178fi179 180echo ""181echo "#------------------------------------------------"182echo ""183 184done # rservers185 186#------------------------------------------------------------------------------------------------------187 188echo "SERVER : LOCAL"189echo ""190if [ ${restart_server} -eq 1 ]; then191 192# local server193/etc/init.d/apache2 reload194echo "#--→ Server Apache LOCAL reloading"195 196else197echo "#--→ Server Apache LOCAL do not reloading (no update certificat)"198fi199 200echo ""201echo "#------------------------------------------------"202echo ""203 204#------------------------------------------------------------------------------------------------------
Pour les lignes "10 à 16" du script ci-dessus "l'authentification avec une paire de clefs", j'ai écris une documentation ici : SSH - SCP par certificats.
Pour lancer la mise à jour par rsync (qui enverra les fichiers (seulement s'ils ont changés) sur les autres serveurs) :
Script avec 1 ligne
001root@web:~ # /root/acme-certif-frontend.bash
La commande envoie les fichiers modifiés sur les autres serveurs et redémare les serveurs Web Apache.
Il faut faire une tâche planifiée tous les jours à l'heure que vous voulez pour rester à jour niveau certificats SSL/TLS.
Par exemple mes tâches planifiées pour ce service ressemble à çà :
Script avec 4 lignes
001root@web:~ # crontab -l002# Lets Encrypt (ACME)00300 00 * * * sleep $(shuf -i 0-3600 -n1) ; "/root/acme"/acme.sh --cron --home "/root/acme" --config-home "/root/acme/data" ; /root/acme-certif-frontend.bash | mail -s "[ZW3B][DNSSEC] Acme + Rsync" "email_1@domain.fr,email_2@domain.fr" > /dev/null00401 00 * * * /root/acme-certif-date_verification.bash | mail -s "[ZW3B][DNSSEC] Date Verification" "email_1@domain.fr,email_2@domain.fr" 1>>/var/log/syslog 2>/dev/null 2>&1
Il manque toujours la mise à jour des champs TLSA du protocole/mécanisme DANE, mais avec cela on a nos sites Web valident et sécurisés et les certificats SSL/TLS transférés et mis à jour sur vos frontaux et sur les autres machines.
Note de Moi-même du 2023/12/22 : J'ai ajouté au script acme-certif-date_verification.bash les mises à jour DNS TLSA du protocole/mécanisme DANE qui sont expliquées" ci-dessous.
Note de Moi-même du 2023/08/08 : Si, vous avez configuré vos champs TLSA du protocole/mécanisme DANE (DNS - based Authentication of Named Entities) qui s'appuie sur le DNS pour authentifier des entités applicatives ; il faut/faudra mettre à jour les RR (Ressource Records) TLSA chaque fois que le certificat TLS/SSL (Let's Encrypt) est mis à jour, renouvelé par acme.sh (tout le 60 jours).
On va donc utiliser "nsupdate" pour mettre à jour dynamiquement les champs d'enregistrement (RR) TLSA (DANE).
Je vous "pose" un exemple :
Script avec 25 lignes
001root@web:~ # vim /root/nsupdate-zw3b_fr.nsupdate002;003server dns.ipv10.net004zone zw3b.fr005;----------------------006; UPDATE DANE007; openssl x509 -noout -fingerprint -sha256 < /root/acme/data/zw3b.fr_ecc/zw3b.fr.cer | tr -d :008; dig TLSA _443._tcp.zw3b.fr @dns.google +short009; ------010;011update del _443._tcp.zw3b.fr. 3600 TLSA012update add _443._tcp.zw3b.fr. 3600 IN TLSA 3 0 1 C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D013update del _443._tcp.www.zw3b.fr. 3600 TLSA014update add _443._tcp.www.zw3b.fr. 3600 IN TLSA 3 0 1 C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D015update del _443._tcp.api.zw3b.fr. 3600 TLSA016update add _443._tcp.api.zw3b.fr. 3600 IN TLSA 3 0 1 C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D017update del _443._tcp.howto.zw3b.fr. 3600 TLSA018update add _443._tcp.howto.zw3b.fr. 3600 IN TLSA 3 0 1 C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D019update del _443._tcp.radio.zw3b.fr. 3600 TLSA020update add _443._tcp.radio.zw3b.fr. 3600 IN TLSA 3 0 1 C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D021update del _443._tcp.mailing.zw3b.fr. 3600 TLSA022update add _443._tcp.mailing.zw3b.fr. 3600 IN TLSA 3 0 1 C1A68D384582BC4A88EC7DB3492678B1B6A6E088036FD90306F4F47AF5B7332D023;024send025;
Et on lance la commande, avec la clef autorisée (allow-update { key "nsupdate-key-zone"; };), pour mettre à jour notre zone DNS.
Script avec 1 ligne
001root@web:~ # nsupdate -k /root/Knsupdate-key-zone.+157+09852.private /root/nsupdate-zw3b_fr.nsupdate
TODO : Il faut, donc "assembler tout çà" ou le faire sois-même en ligne de commande chaque fois que le certificat TLS/SSL Let's Encrypt change.
En passant dans le script :/root/acme-certif-date_verification.bash; il faut vérifier que toutes les entitées (sous-domaine, ports, protocoles) "Suject Alt name" soient bien signées DANE et non pas seulement, sur le nom domainedomain.tldentcpsur le port443.
Le principe du protocole de sécurité DANE (DNS-based Authentication of Named Entities).
Bon courage.
Salutations,
Romain


