Publié le 17/02/2023

Dépendances systèmes

  • Certbot, pour récupérer un certificat validé par une haute autorité

Certbot

La (seule?) raison pour laquelle on pourrait vouloir Certbot sur un NAS home-made, c'est :

  1. Soit pour exposer un service Web: un site, une application, ...
  2. Soit parce que Google exige que la source d'un stream vers une Chromecast dispose d'un certificat signé.
sudo apt install certbot python3-certbot-nginx nginx
~$ sudo certbot --nginx -d <domain_name>
When trying to update a password, this return status indicates that the value provided as the current password is not correct.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): <email_address>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Account registered.
Requesting a certificate for hq.grimbox.be

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/hq.grimbox.be/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/hq.grimbox.be/privkey.pem
This certificate expires on 2023-01-07.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for hq.grimbox.be to /etc/nginx/conf.d/hq.grimbox.be.conf
Congratulations! You have successfully enabled HTTPS on https://hq.grimbox.be

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Certbot s'occupera lui-même d'installer le certificat pour les sites configurés, en configurant le protocole HTTPS et en réalisant une redirection du protocole HTTP vers HTTPS si un vil malandrin innocent venait à s'y connecter sur le port 80.

Auto renew

Le plus simple (à mon sens) pour renouveler automatiquement les certificats, consiste à créer une tâche cron et à y mettre la commande certbot -q renew qui va simplement s'occuper de renouveler le certificat si l'actuel expire dans les 30 prochains jours.

crontab -e

Et on ajoute @daily certbot -q renew quelque part dans les commandes déjà programmées. Inutile de tenter un renouvellement tous les jours (ce serait sans doute inutile) ou tous les mois (cela pourrait être un chouia trop court).