Outils pour utilisateurs

Outils du site


let_s_encrypt

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
Dernière révisionLes deux révisions suivantes
let_s_encrypt [2018/01/10 01:48] simonlet_s_encrypt [2019/09/12 19:46] simon
Ligne 3: Ligne 3:
  
 ===== Configuration des certificats Let's Encrypt ===== ===== Configuration des certificats Let's Encrypt =====
-J'ai configuré les certificats pour plusieurs noms de domaines et voici la procédure suivie, pour le domaine fictif "plouf.com"+=== Acme.sh === 
- +[[https://github.com/Neilpang/acme.sh|acme.sh (github)]] est un client pour Let's Encrypt écrit en [[bash]], avec très peu de dépendances.
-J'ai utilisé l'outil [[https://github.com/diafygi/acme-tiny|acme-tiny]], on commence par le télécharger et l'installer.+
  
 +La première chose est d'installer acme.sh en suivant la [[https://github.com/Neilpang/acme.sh#1-how-to-install|procédure d'installation]]. 
 <code bash> <code bash>
-wget https://raw.githubusercontent.com/diafygi/acme-tiny/master/acme_tiny.py -O /usr/local/bin/acme-tiny.py +apt install socat 
---2018-01-10 02:30:22--  https://raw.githubusercontent.com/diafygi/acme-tiny/master/acme_tiny.py +# curl https://get.acme.sh sh 
-Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.120.133 +</code>
-Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.120.133|:443... connected. +
-HTTP request sent, awaiting response... 200 OK +
-Length: 9179 (9.0K) [text/plain] +
-Saving to: ‘/usr/local/bin/acme-tiny.py’+
  
-/usr/local/bin/acme-tiny.py         100%[================================================================>  8.96K  --.-KB/s    in 0s      +Ensuite, il faut avoir un domaine déjà configuré en HTTP, avec un dossier accessible. Une fois que c'est fait, il n'y a plus qu'à suivre les [[https://github.com/Neilpang/acme.sh#2-just-issue-a-cert|exemples sur le github du projet]] :
  
-2018-01-10 02:30:22 (51.4 MB/s) /usr/local/bin/acme-tiny.py’ saved [9179/9179]+<code bash> 
 +# acme.sh --issue -d plouf.com -d www.plouf.com -w /var/www/plouf/
 </code> </code>
  
-On crée un dossier pour Let's Encrypt, avec les bons droits :+__**Bonus :**__ L'installation d'acme.sh ajoute directement une ligne dans le cron 
 <code bash> <code bash>
-# mkdir /etc/letsencrypt +4 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh"/dev/null
-# chown root:ssl-cert /etc/letsencrypt/ +
-# chmod 750 /etc/letsencrypt/+
 </code> </code>
  
-On se déplace dans le dossier qu'on vient de créer :+== Choisir une clé ECC et sa taille ==
 <code bash> <code bash>
-cd /etc/letsencrypt/+acme.sh --issue -d plouf.com -d www.plouf.com -w /var/www/plouf/ --keylength ec-384
 </code> </code>
  
-Et on lance la génération d'une clé privée :+== Wildcard ==
 <code bash> <code bash>
 +$ acme.sh --issue -d artanux.be -d '*.artanux.be' --dns dns_ovh --keylength ec-384
 </code> </code>
  
 +Détails sur la page [[acme.sh]].
  
 +== Arrêter le renouvellement d'un certificat ==
 +Les explications sont sur [[https://github.com/Neilpang/acme.sh#13-how-to-stop-cert-renewal|la page github]] mais le plus simple est de supprimer le dossier correspondant :
 +<code bash>
 +# rm -r ~/.acme.sh/plouf.com
 +</code>
 +
 +=== Certbot ===
 +<WRAP center round important 60%>
 +Cette partie est un peu ancienne et plus forcément pertinente...
 +</WRAP>
 +
 +J'ai configuré les certificats pour plusieurs noms de domaines et voici la procédure suivie, pour le domaine fictif "plouf.com".
  
-NOUVELLE SOLUTION :+On commence par activer les backports (sous Stretch) afin de bénéficier de la version de [[certbot]] la plus récente.
  
 <code bash> <code bash>
-# apt install python-certbot-apache+vim /etc/apt/sources.list 
 +  #(...ajouter à la fin du fichier :) 
 +  # Backports repository 
 +  deb http://ftp.debian.org/debian stretch-backports main
 </code> </code>
-<hidden>+ 
 +Dans mon cas, après installation sans les backports, certbot était en version 0.10 alors qu'avec les backports, on a la version 0.19.0. 
 + 
 +<code bash> 
 +# apt-get -t stretch-backports install python-certbot-apache 
 +</code> 
 <code bash> <code bash>
-Reading package lists... Done +certbot --version 
-Building dependency tree        +certbot 0.19.0
-Reading state information... Done +
-The following additional packages will be installed: +
-  augeas-lenses certbot libaugeas0 python-acme python-augeas python-certbot python-chardet python-configargparse python-configobj +
-  python-dnspython python-funcsigs python-mock python-openssl python-parsedatetime python-pbr python-psutil python-pyicu python-requests +
-  python-rfc3339 python-tz python-urllib3 python-zope.component python-zope.event python-zope.hookable python-zope.interface +
-Suggested packages: +
-  augeas-doc python-certbot-doc augeas-tools python-acme-doc python-certbot-apache-doc python-configobj-doc python-funcsigs-doc +
-  python-mock-doc python-openssl-doc python-openssl-dbg python-psutil-doc python-socks python-ntlm +
-The following NEW packages will be installed: +
-  augeas-lenses certbot libaugeas0 python-acme python-augeas python-certbot python-certbot-apache python-chardet python-configargparse +
-  python-configobj python-dnspython python-funcsigs python-mock python-openssl python-parsedatetime python-pbr python-psutil python-pyicu +
-  python-requests python-rfc3339 python-tz python-urllib3 python-zope.component python-zope.event python-zope.hookable +
-  python-zope.interface +
-upgraded, 26 newly installed, 0 to remove and 0 not upgraded. +
-Need to get 2,133 kB of archives. +
-After this operation, 9,863 kB of additional disk space will be used. +
-Do you want to continue? [Y/n] +
-(...)+
 </code> </code>
 +
 +<WRAP center round alert 60%>
 +Sur une installation plus récente, j'ai du passer par [[pip]] pour installer certbot 0.21. L'installation depuis les backports ne fonctionnait pas. 
 +</WRAP>
  
  
Ligne 72: Ligne 76:
 # certbot --apache # certbot --apache
 Saving debug log to /var/log/letsencrypt/letsencrypt.log Saving debug log to /var/log/letsencrypt/letsencrypt.log
 +Plugins selected: Authenticator apache, Installer apache
  
 Which names would you like to activate HTTPS for? Which names would you like to activate HTTPS for?
 ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
 1: plouf.com 1: plouf.com
-2: sous.plouf.com +2: chat.plouf.com 
-3: piscine.plouf.com+3: wiki.plouf.com
 ------------------------------------------------------------------------------- -------------------------------------------------------------------------------
 Select the appropriate numbers separated by commas and/or spaces, or leave input Select the appropriate numbers separated by commas and/or spaces, or leave input
-blank to select all options shown (Enter 'c' to cancel):1,2,3 +blank to select all options shown (Enter 'c' to cancel): 1
-Enter email address (used for urgent renewal and security notices) (Enter 'c' to +
-cancel):mon@mail.com +
- +
-------------------------------------------------------------------------------- +
-Please read the Terms of Service at +
-https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must +
-agree in order to register with the ACME server at +
-https://acme-v01.api.letsencrypt.org/directory +
-------------------------------------------------------------------------------- +
-(A)gree/(C)ancel: A+
 Obtaining a new certificate Obtaining a new certificate
 Performing the following challenges: Performing the following challenges:
-tls-sni-01 challenge for plouf.com +tls-sni-01 challenge for caliban.be
-tls-sni-01 challenge for sous.plouf.com +
-tls-sni-01 challenge for piscine.plouf.com+
 Enabled Apache socache_shmcb module Enabled Apache socache_shmcb module
 Enabled Apache ssl module Enabled Apache ssl module
 Waiting for verification... Waiting for verification...
 Cleaning up challenges Cleaning up challenges
-Generating key (2048 bits): /etc/letsencrypt/keys/0000_key-certbot.pem +Created an SSL vhost at /etc/apache2/sites-available/plouf.com-le-ssl.conf
-Creating CSR: /etc/letsencrypt/csr/0000_csr-certbot.pem +
-Created an SSL vhost at /etc/apache2/sites-available/vps89550.ovh.net-le-ssl.conf+
 Enabled Apache socache_shmcb module Enabled Apache socache_shmcb module
 Enabled Apache ssl module Enabled Apache ssl module
-Deploying Certificate to VirtualHost /etc/apache2/sites-available/vps89550.ovh.net-le-ssl.conf +Deploying Certificate for caliban.be to VirtualHost /etc/apache2/sites-available/plouf.com-le-ssl.conf 
-Enabling available site: /etc/apache2/sites-available/vps89550.ovh.net-le-ssl.conf +Enabling available site: /etc/apache2/sites-available/plouf.com-le-ssl.conf
-An unexpected error occurred: +
-StopIteration +
-Please see the logfiles in /var/log/letsencrypt for more details.+
  
-IMPORTANT NOTES: +Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access
- - Unable to install the certificate +------------------------------------------------------------------------------- 
- - Congratulations! Your certificate and chain have been saved at +1: No redirect - Make no further changes to the webserver configuration. 
-   /etc/letsencrypt/live/caliban.be/fullchain.pemYour cert will +2: Redirect Make all requests redirect to secure HTTPS access. Choose this for 
-   expire on 2018-04-10. To obtain a new or tweaked version of this +new sitesor if you're confident your site works on HTTPS. You can undo this 
-   certificate in the future, simply run certbot again with the +change by editing your web server's configuration
-   "certonly" optionTo non-interactively renew *all* of your +------------------------------------------------------------------------------- 
-   certificatesrun "certbot renew" +Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 
- - If you lose your account credentials, you can recover through +Redirecting vhost in /etc/apache2/sites-enabled/cplouf.com.conf to ssl vhost in /etc/apache2/sites-available/plouf.com-le-ssl.conf
-   e-mails sent to moi@simonlefort.be+
- Your account credentials have been saved in your Certbot +
-   configuration directory at /etc/letsencryptYou should make a +
-   secure backup of this folder nowThis configuration directory will +
-   also contain certificates and private keys obtained by Certbot so +
-   making regular backups of this folder is ideal. +
-</code>+
  
-<code bash> +------------------------------------------------------------------------------- 
-</code>+Congratulations! You have successfully enabled https://plouf.com
  
-<code bash> +You should test your configuration at: 
-</code>+https://www.ssllabs.com/ssltest/analyze.html?d=plouf.com 
 +-------------------------------------------------------------------------------
  
-<code bash> +IMPORTANT NOTES: 
-</code>+ - Congratulations! Your certificate and chain have been saved at: 
 +   /etc/letsencrypt/live/plouf.com-0001/fullchain.pem 
 +   Your key file has been saved at: 
 +   /etc/letsencrypt/live/plouf.com-0001/privkey.pem 
 +   Your cert will expire on 2018-04-10. To obtain a new or tweaked 
 +   version of this certificate in the future, simply run certbot again 
 +   with the "certonly" option. To non-interactively renew *all* of 
 +   your certificates, run "certbot renew" 
 + - If you like Certbot, please consider supporting our work by:
  
-<code bash>+   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate 
 +   Donating to EFF:                    https://eff.org/donate-le
 </code> </code>
  
 +On peut tester un renouvellement des certificats avec la commande suivante : 
 <code bash> <code bash>
 +# certbot renew --dry-run
 </code> </code>
  
-<code bash> +Actuellement, ça foire chez moi... Pas encore compris pourquoi.
-</code>+
  
 +==== Clés plus longues ====
 <code bash> <code bash>
 +# certbot certonly -a webroot --rsa-key-size 4096 --webroot-path=/var/www/plouf.com -d plouf.com -d www.plouf.com
 </code> </code>
- 
-<code bash> 
-</code> 
- 
-<code bash> 
-</code> 
- 
-<code bash> 
-</code> 
- 
 ===== Sources ===== ===== Sources =====
   * [[https://www.sysnove.fr/blog/2016/03/utilisation-pratique-letsencrypt-acme-tiny.html|Sysnove.fr]]   * [[https://www.sysnove.fr/blog/2016/03/utilisation-pratique-letsencrypt-acme-tiny.html|Sysnove.fr]]