Auteur Sujet: Certificat expiré  (Lu 2380 fois)

0 Membres et 1 Invité sur ce sujet

vivien

  • Administrateur
  • *
  • Messages: 47 182
    • Twitter LaFibre.info
Certificat expiré
« Réponse #12 le: 08 septembre 2022 à 13:07:14 »
Non, je ne pense pas que Certbot, le script que j'utilise pour renouveler le certificat, relance Apache.

Je pensais que c'était fait par logrotate.

Dans le fichier /etc/logrotate.d/apache2 j'ai :
/var/log/apache2/*.log {
daily
missingok
rotate 3
nocompress
notifempty
create 644 root adm
sharedscripts
postrotate
                if invoke-rc.d apache2 status > /dev/null 2>&1; then \
                    invoke-rc.d apache2 reload > /dev/null 2>&1; \
                fi;
endscript
prerotate
if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
run-parts /etc/logrotate.d/httpd-prerotate; \
fi; \
endscript
}

Dans le passé, j'ai souvenir que logrotate relançait Apache pour le changement de nom de fichier de log et dans le fichier /etc/apache2/mods-enabled/mpm_event.conf, j'avais mis "GracefulShutdownTimeout 3600" pour que les connexions ouvertes sans fin soient fermées après 1h, car j'avais été confronté à des connexions ouvertes pendant des dizaines d'heures (slowDDoS ?) qui bloquait le redémmarrage d'Apache.

Maintenant que logrotate ne relance plus régulièrement Apache, il faut probablement mettre une commande à Apache pour qu'un process Apache n'ait pas une durée de vie infinie.

alain_p

  • Abonné Free fibre
  • *
  • Messages: 16 245
  • Delta S 10G-EPON sur Les Ulis (91)
Certificat expiré
« Réponse #13 le: 08 septembre 2022 à 13:22:27 »
Pour mon expérience, c'est plutôt nginx que l'on utilise, et certbot relance bien nginx, en tout cas avec Letsencrypt. Certbot peut être utiliser aussi pour renouveler des certificats Sectigo, par exemple, mais là, il faut modifier à la main la configuration, et relancer le serveur web.

https://sectigo.com/resource-library/sectigos-acme-automation

hwti

  • Abonné Orange Fibre
  • *
  • Messages: 2 237
  • Chambly (60)
Certificat expiré
« Réponse #14 le: 08 septembre 2022 à 13:23:57 »
En effet, logrotate devrait appeler "invoke-rc.d apache2 reload" (cad "systemctl apache2 reload") tous les jours.

Tu peux regarder avec "journalctl --unit=apache2" (ou dans les /var/log/syslog* si tu n'as pas journald).
Normalement tous les jours tu dois avoir :
systemd[1]: Reloading The Apache HTTP Server.
systemd[1]: Reloaded The Apache HTTP Server.

vivien

  • Administrateur
  • *
  • Messages: 47 182
    • Twitter LaFibre.info
Certificat expiré
« Réponse #15 le: 08 septembre 2022 à 14:19:41 »
certbot relance bien nginx

Quand je demande un certificat à certbot, je le demande en mode "certonly" pour qu'il ne touche pas à ma configuration Apache :
sudo certbot --apache --domains lafibre.info,www.lafibre.info certonly

Sinon Apache est bien relancé par logrotate, il le fait même 4 fois chaque jour !

Log pour lafibre.info :
sept. 01 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 01 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 01 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 01 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 02 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 02 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 02 00:00:03 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 02 00:00:03 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 03 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 03 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 03 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 03 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 04 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 04 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 04 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 04 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 05 00:00:03 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 05 00:00:03 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 05 00:00:04 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 05 00:00:04 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 06 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 06 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 06 00:00:03 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 06 00:00:03 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 07 00:00:02 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 07 00:00:02 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 07 00:00:03 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 07 00:00:03 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 08 00:00:00 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 08 00:00:00 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 08 00:00:01 lafibre systemd[1]: Reloading The Apache HTTP Server.
sept. 08 00:00:01 lafibre systemd[1]: Reloaded The Apache HTTP Server.
sept. 08 09:29:46 lafibre systemd[1]: Stopping The Apache HTTP Server...
sept. 08 09:29:56 lafibre systemd[1]: apache2.service: Succeeded.
sept. 08 09:29:56 lafibre systemd[1]: Stopped The Apache HTTP Server.
-- Reboot --
sept. 08 09:30:56 lafibre systemd[1]: Starting The Apache HTTP Server...
sept. 08 09:30:56 lafibre systemd[1]: Started The Apache HTTP Server.

alain_p

  • Abonné Free fibre
  • *
  • Messages: 16 245
  • Delta S 10G-EPON sur Les Ulis (91)
Certificat expiré
« Réponse #16 le: 08 septembre 2022 à 14:55:12 »
J'utilise certbot dans le mode pas défaut, run. Pour nginx, de mon expérience, il touche à la configuration de façon propre, sans rien casser autrement. C'est quand même plus sûr qu'il fasse tout automatiquement, on n'a pas à intervenir, par exemple si on est indisponible, en congés... C'est l'assurance que le certificat sera bien renouvelé.

xp25

  • Abonné RED by SFR fibre FttH
  • *
  • Messages: 5 938
Certificat expiré
« Réponse #17 le: 08 septembre 2022 à 15:02:44 »
Pourquoi ne pas mettre un certificat pour 2 ans ?

Orange fait ça ici -> https://www.digicert.com/fr/tls-ssl/compare-certificates

alain_p

  • Abonné Free fibre
  • *
  • Messages: 16 245
  • Delta S 10G-EPON sur Les Ulis (91)
Certificat expiré
« Réponse #18 le: 08 septembre 2022 à 15:09:02 »
Parce que Google, Apple... n'acceptent plus les certificats de plus d'un an. De ce côté là aussi, Letsencrypt, qui les renouvelle tous les 3 mois, est très pratique. Il est plus facile de révoquer un certificat qui a une durée de vie limitée, qui viendra de toute façon à expiration, qu'un à longue durée.

https://www.hosteur.com/ressources/articles/validite-ssl

hwti

  • Abonné Orange Fibre
  • *
  • Messages: 2 237
  • Chambly (60)
Certificat expiré
« Réponse #19 le: 08 septembre 2022 à 15:27:09 »
Sinon Apache est bien relancé par logrotate, il le fait même 4 fois chaque jour !
C'est deux fois (reloading, reloaded c'est le début et la fin de la même action), et immédiatement l'une derrière l'autre (peut-être que ça peut déclencher le bug).

vivien

  • Administrateur
  • *
  • Messages: 47 182
    • Twitter LaFibre.info
Certificat expiré
« Réponse #20 le: 08 septembre 2022 à 16:50:16 »
Le double reload est lié au fait que j'ai deux dossiers pour les logs avec des durées différentes.

- /var/log/apache2/ est en ramdisque avec une durée de seulement 3 jours.
- /home/log/ est sur SSD avec une durée de 70 jours

L'objectif est de limiter les écritures sur SSD pour ce qui n'est pas important.

Voici mon fichier /etc/logrotate.d/apache2 complet :
/var/log/apache2/*.log {
        daily
        missingok
        rotate 3
        nocompress
        notifempty
        create 644 root adm
        sharedscripts
        postrotate
                if invoke-rc.d apache2 status > /dev/null 2>&1; then \
                    invoke-rc.d apache2 reload > /dev/null 2>&1; \
                fi;
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}

/home/log/*/*.log {
        daily
        missingok
        rotate 70
        nocompress
        notifempty
        create 644 root adm
        sharedscripts
        postrotate
                if invoke-rc.d apache2 status > /dev/null 2>&1; then \
                    invoke-rc.d apache2 reload > /dev/null 2>&1; \
                fi;
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}


Il y a peut-être un moyen de faire ça plus proprement.