modification du challenge pour certbot

This commit is contained in:
2025-03-09 16:04:54 +01:00
parent a81189e5d2
commit b3d3313e61

View File

@@ -101,16 +101,25 @@ setup_ssl() {
echo "🔄 Test de génération dun nouveau certificat SSL via HTTP..."
while true; do
certbot certonly --standalone --dry-run -d "$fqdn" --non-interactive --agree-tos --register-unsafely-without-email
# Vérification que le dossier webroot existe
webroot_path="/var/www/cedrix"
if [[ ! -d "$webroot_path" ]]; then
echo "❌ Le dossier $webroot_path n'existe pas. Apache n'a pas été installé..."
exit 1
fi
echo "🔍 Test de génération de certificat via webroot ($webroot_path)..."
certbot certonly --webroot -w "$webroot_path" --dry-run -d "$fqdn" --non-interactive --agree-tos --register-unsafely-without-email
if [[ $? -eq 0 ]]; then
echo "✅ Test réussi, génération réelle du certificat..."
certbot certonly --standalone -d "$fqdn" --non-interactive --agree-tos --register-unsafely-without-email
certbot certonly --webroot -w "$webroot_path" -d "$fqdn" --non-interactive --agree-tos --register-unsafely-without-email
break
else
echo "⚠️ Échec du test via HTTP. Tentative via DNS..."
echo "🔄 Test de génération dun nouveau certificat SSL via challenge DNS..."
echo "🛠️ Veuillez ajouter un enregistrement TXT pour _acme-challenge.$fqdn avec la valeur fournie par certbot."
while true; do
certbot certonly --manual --preferred-challenges dns --dry-run -d "$fqdn" --non-interactive --agree-tos --register-unsafely-without-email
if [[ $? -eq 0 ]]; then
@@ -132,6 +141,7 @@ setup_ssl() {
done
fi
done
echo "✅ Certificat SSL généré avec succès."
}