LetsEncrypt

De Hegyd Doc.

(Différences entre les versions)
(Installation d’un certificat LetsEncrypt avec renouvellement automatique pour un NDD :)
(Installation)
 
(3 versions intermédiaires masquées)
Ligne 5 : Ligne 5 :
* Ticket : https://v2.produhost.net/panel/15744/support/ticket/205183
* Ticket : https://v2.produhost.net/panel/15744/support/ticket/205183
-
''Sur le serveur intrastore.hegyd.net
+
''''Sur le serveur intrastore.hegyd.net''
-
Générer un certificat SSL pour candidats.raisonhome.com par Let's Encrypt avec renouvellement automatique.
+
''Générer un certificat SSL pour candidats.raisonhome.com par Let's Encrypt avec renouvellement automatique.''
-
Redirection auto port 80 vers 443
+
''Redirection auto port 80 vers 443''
-
...''
+
''...''''
Ligne 28 : Ligne 28 :
https://certbot.eff.org/lets-encrypt/debianjessie-apache
https://certbot.eff.org/lets-encrypt/debianjessie-apache
-
* faire l’installation
 
-
  - Se connecter en root, sur intrastore.hegyd.net:
+
* Se connecter en root, sur intrastore.hegyd.net:
-
  - Vérifier si l’ancien certbot n’esp installé  :  
+
* Vérifier si l’ancien certbot n’est pas installé  :  
<pre>
<pre>

Version actuelle en date du 6 janvier 2021 à 14:29

[modifier] Installation d’un certificat LetsEncrypt avec renouvellement automatique pour un NDD :

''Sur le serveur intrastore.hegyd.net Générer un certificat SSL pour candidats.raisonhome.com par Let's Encrypt avec renouvellement automatique. Redirection auto port 80 vers 443 ...''


L'utilisation de certbot-auto est recommandé car les versions du "acme-challenge" du certbot de la distribution ( dépôts backports ) ne sont plus supportées.

[modifier] Installation

  • Récupération de l’os et de sa version sur intrastore.hegyd.net
#cat /etc/debian_version
8.11

ici Debian / Jessie

https://certbot.eff.org/lets-encrypt/debianjessie-apache


  • Se connecter en root, sur intrastore.hegyd.net:
  • Vérifier si l’ancien certbot n’est pas installé  :
apt remove certbot

puis :

wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto
  • Installer les dépendances, python et générer les certificats :
 
/usr/local/bin/certbot-auto –apache
  • En cas d’erreur, faire les modifications nécessaire et relancer la commande.
 
/usr/local/bin/certbot-auto –apache
  • Ensuite on teste le certificat :
 
certbot-auto certonly --webroot -w /var/projects/cloud/prod/raison-home -d candidats.raisonhome.com -m tech@hegyd.net –dry-run
  • si c’est ok on enleve le « --dry-run »
 
certbot-auto certonly --webroot -w /var/projects/cloud/prod/raison-home -d candidats.raisonhome.com -m tech@hegyd.net 
  • Le certificat va être généré dans /etc/letsencrypt/live/candidats.raisonhome.com qui contient les fichiers pour le certificat à configurer dans le vhost Apache :

cert.pem chain.pem fullchain.pem privkey.pem

  • modifier la conf du vhost dans /etc/apache2/sites-enabled/intrastore.conf:
# PROD candidats.raisonhome.com
<Virtualhost *:80>
        ServerName candidats.raisonhome.com 
        ServerAlias *.candidats.raisonhome.com
        VirtualDocumentRoot /var/projects/cloud/prod/raison-home
        <Directory "/var/projects/cloud/prod/raison-home">
                Options Indexes FollowSymlinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
       RewriteEngine On
       RewriteCond %{HTTPS} off
       RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Virtualhost>
<Virtualhost *:443>
        ServerName candidats.raisonhome.com 
        ServerAlias *.candidats.raisonhome.com
        VirtualDocumentRoot /var/projects/cloud/prod/raison-home
        <Directory "/var/projects/cloud/prod/raison-home">
                Options Indexes FollowSymlinks MultiViews
                AllowOverride All
                Require all granted
        </Directory>
        SSLEngine On
        SSLCertificateFile /etc/letsencrypt/live/candidats.raisonhome.com/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/candidats.raisonhome.com/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/candidats.raisonhome.com/chain.pem
</Virtualhost>
  • Vérifier la configuration et recharger apache :
apachectl -t
service apache2 reload
  • Vérifier le site, la redirection et le certificat :
https://candidats.raisonhome.com

[modifier] installation du cron de renouvellement ( renew )

  • Ensuite mettre le cron de renouvellement dans la crontab :
echo "0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew -q" | sudo tee -a /etc/crontab > /dev/null
  • ce qui donne pour etc/crontab
0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew -q
  • Recharger le service cron
service cron reload

Et voila, reste à surveiller le cron pour valider le bon renouvellement automatique.