Aller au contenu principal
SSL Let's Encrypt : Installation et configuration sur Debian 11

Let's Encrypt est une autorité de certification lancée le 3 décembre 2015, elle permet d'obtenir gratuitement un certificat SSL pour un ou plusieurs domaines.

Pour generer un certificat, le demandeur doit prouver qu'il est le proprietaire du domaine. Plusieurs methodes sont utilisés, mais dans cet article nous aborderons la mise en place de deux methodes de challenge : Challenge HTTP-01 et Challenge DNS-01.

Pour faciliter l'integration des methodes de challenge plusieurs application sont disponible donc voici quelques une :

 

Utilisation de cerbot sur un domaine ou sous domaine

Installation 

sudo apt  install certbot python3-certbot-apache 

Apres installation on fait un test sur un domaine :

sudo certbot certonly --apache -d nicamex-exhibition.com -d www.nicamex-exhibition.com --dry-run 

L'option --dry-run permet une simulation, afin de se rassurer que cela fonctionne.

L'option -d pour specifier un nom de domaine ou sous domaine.

Le resultat devrait être similaire à :

... 
IMPORTANT NOTES:
 - The dry run was successful.

à partir de la vous pouvez essayer de demander la generation de votre certificat :

sudo certbot certonly --apache -d habeuk.com -d www.habeuk.com 

Resultat :

... 
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/nicamex-exhibition.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/nicamex-exhibition.com/privkey.pem
   Your certificate will expire on 2023-05-06. To obtain a new or
   tweaked version of this certificate in the future, simply run
   certbot again. To non-interactively renew *all* of your
   certificates, run "certbot renew"
 - 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

Votre certificat est generé il ne reste plus qu'à mettre à jour votre fichier VirtualHost.

<VirtualHost *:80> 
        ServerAdmin kksasteph888@gmail.com
        ServerName      nicamex-exhibition.com
        ServerAlias     www.nicamex-exhibition.com
        DocumentRoot /var/www/nicamex_expo/public/web
        <Directory /var/www/nicamex_expo/public/web>
                Options Indexes FollowSymLinks
                AllowOverride All
                Order Deny,Allow
                Allow from all
        </Directory>
        ErrorLog /var/www/nicamex_expo/logs/error.log
        CustomLog /var/www/nicamex_expo/logs/access.log  combined
      
      #redirect to https
      RewriteEngine On
      RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin kksasteph888@gmail.com
        ServerName nicamex-exhibition.com
        ServerAlias     www.nicamex-exhibition.com
        DocumentRoot /var/www/nicamex_expo/public/web
        <Directory /var/www/nicamex_expo/public/web>
                Options Indexes FollowSymLinks
                AllowOverride All
                Order Deny,Allow
                Allow from all
        </Directory>
        ErrorLog /var/www/nicamex_expo/logs/error.log
        CustomLog /var/www/nicamex_expo/logs/access.log combined
#SSL conf.
SSLCertificateFile /etc/letsencrypt/live/nicamex-exhibition.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/nicamex-exhibition.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Svp, adapter les données en fonction de votre environnement.

Les données au niveau de #SSL conf sont fournis lors de la creation en dessous de "IMPORTANT NOTES".
 

Vous pouvez laisser certbot mettre à jour votre configuration sur apache en enlevant "certonly" dans la commande de génération du certificat.  

Generation des certificats pour tous les sous-domaines :

Dans cette partie nous allons voir comment mettre en place certificat pour un domaine et les sous domaines.

sudo apt update
sudo apt install certbot python3-certbot-dns-ovh
Creer un fichier de configuration /root/.ovhapi
dns_ovh_endpoint = ovh-eu  # "ovh-eu" pour OVH Europe, "ovh-ca" pour OVH Canada
dns_ovh_application_key = YOUR_APPLICATION_KEY
dns_ovh_application_secret = YOUR_APPLICATION_SECRET
dns_ovh_consumer_key = YOUR_CONSUMER_KEY
Créez une application dans l'API OVH (remplacez eu par ca si vous êtes au Canada).

Effectuer un test de generation :
sudo certbot certonly --dns-ovh --dns-ovh-credentials /root/.ovhapi -d exemple.com -d *.exemple.com --dry-run
Tester le renouvelement: ( NB le renouvellement se ferra de maniere automatique )
sudo certbot renew --dry-run

Si tout est ok, Lancer la generation en supprimant --dry-run
sudo certbot certonly --dns-ovh --dns-ovh-credentials /root/.ovhapi -d exemple.com -d *.exemple.com

Verification:
Verifier que ce fichier exite : /etc/letsencrypt/options-ssl-nginx.conf
si cest pas le cas installé le paquet python3-certbot-nginx ou python3-certbot-nginx ou python3-certbot-apache
sudo apt install python3-certbot-apache
#ou 
sudo apt install python3-certbot-nginx
Copier le fichier : options-ssl-nginx.conf
sudo cp /usr/lib/python3/dist-packages/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf /etc/letsencrypt/
Generer le fichier ssl-dhparams.pem :
sudo openssl dhparam -out /etc/letsencrypt/ssl-dhparams.pem 2048
si vous etez sous nginx.
 
sudo nginx -t
sudo systemctl restart nginx
si vous etez sous apache
sudo systemctl restart apache2


 
Profile picture for user admin Stephane K

Écrit le

Il y'a 2 ans
Modifié
Il y'a 2 jours
Loading ...
WhatsApp
Support Habeuk : +237 694 900 622
WhatsApp Send