Installation : CERTBOT

Debian 9 : plus besoin d'activer les backports, royal :

apt-get install certbot ca-certificates

Si l'on est sur un système ne proposant pas Certbot (ou une vieille version qui déconne, bisous Alpine Linux), on peut passer le paquet acme.sh via son dépôt : https://github.com/Neilpang/acme.sh

Apache

Création de la clé dhparams :

openssl dhparam -out /etc/ssl/private/dhparams.pem 4096

Config :

#Base :80
<VirtualHost *:80>
    ServerAdmin my@mail.com
    DocumentRoot /var/www/my.domain.tld
    ServerName my.domain.tld
    ErrorLog /var/log/apache2/my.domain.tld.error.log
    CustomLog /var/log/apache2/my.domain.tld.access.log combined
    
    #Redirect all to https
    Redirect permanent / https://my.domain.tld/
 
    <Directory /var/www/my.domain.tld>
            AllowOverride FileInfo AuthConfig Limit Options
            Options +MultiViews +FollowSymLinks +IncludesNoExec -Indexes
            Order allow,deny
            Allow from all
    </Directory>
</VirtualHost>
#https :443
<VirtualHost *:443>
    ServerAdmin my@mail.com
    DocumentRoot /var/www/my.domain.tld
    ServerName my.domain.tld
    ErrorLog /var/log/apache2/my.domain.tld.error.log
    CustomLog /var/log/apache2/my.domain.tld.access.log combined
    <Directory /var/www/my.domain.tld>
            AllowOverride FileInfo AuthConfig Limit Options
            Options +MultiViews +FollowSymLinks +IncludesNoExec -Indexes
            Order allow,deny
            Allow from all
    </Directory>

    Include ssl.conf

    SSLCertificateFile   /etc/letsencrypt/live/my.domain.tld/fullchain.pem
    SSLCACertificateFile /etc/letsencrypt/live/my.domain.tld/fullchain.pem
    SSLCertificateChainFile /etc/letsencrypt/live/my.domain.tld/chain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/my.domain.tld/privkey.pem
    #Si pas déclaré déjà dans le fichier /etc/apache2/custom.conf, déclarer ici le fichier DHParams :
    #SSLDHParametersFile /etc/ssl/private/dhparams.pem
</VirtualHost>

Pour le fichier ssl.conf, voir Apache : SSL
Renew :

./certbot certonly --webroot -w /var/www/my.domain.tld/ -d my.domain.tld --rsa-key-size 4096

Si un .htaccess bloque l'accès aux fichiers, l'éditer :

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/.well-known/acme-challenge/
RewriteRule "^.well-known/acme-challenge" - [L]

Nginx

Config :

server {
       listen 80;
       server_name my.domain.tld;

       location /.well-known/acme-challenge {
              root /my/path/html/letsencrypt;
       }

       location / {
              return 301 https://$server_name$request_uri;
       }
}

server {
       listen 443 ssl http2;
       server_name my.domain.tld;
 
       root /my/path/html;
       index index.html;
       
       ssl on;
       ssl_certificate /etc/letsencrypt/live/my.domain.tld/fullchain.pem;
       ssl_certificate_key /etc/letsencrypt/live/my.domain.tld/privkey.pem;
       ssl_client_certificate /etc/letsencrypt/live/my.domain.tld/cert.pem;
       ssl_trusted_certificate /etc/letsencrypt/live/my.domain.tld/chain.pem;

       ssl_stapling on;
       ssl_stapling_verify on;
       ssl_session_timeout 1d;
       ssl_session_tickets off;
}

Création de la clé dhparams (avec Memo-Linux) :

openssl dhparam -out /etc/ssl/private/dhparams.pem 4096

On édite du côté Nginx :

nano /etc/nginx/nginx.conf
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_dhparam /etc/ssl/private/dhparams.pem;

Test Nginx si tout ok :

nginx -t

Renew :

./certbot certonly --webroot -w /my/path/html/ --agree-tos --email my@mail.com -d my.domain.tld --rsa-key-size 4096

Nginx - Reverse Proxy

Debian Stretch

apt-get install certbot python-certbot-nginx
certbot --nginx -d sub.libox.fr

Génération des certificats préliminaires

On crée le dossier les contenant, et on s'y déplace :

mkdir /etc/nginx/my_ssl_keys/
cd /etc/nginx/my_ssl_keys

On génère la clé (en rentrant les infos souhaitées), et le certificat :

openssl genrsa -out my.domain.tld.key 4096
openssl req -new -key my.domain.tld.key -out my.domain.tld.csr
openssl x509 -req -days 365 -in my.domain.tld.csr -signkey my.domain.tld.key -out my.domain.tld.crt

On génère le dhparam :

openssl dhparam -out /etc/ssl/private/dhparams.pem 4096

Génération Let's Encrypt - Certbot

certbot certonly -d my.domain.tld --rsa-key-size 4096

Configuration Nginx

server {
       listen 80;
       server_name my.domain.tld;
       return 301 https://$server_name$request_uri;
}

server {
       listen 443 ssl http2;
       server_name my.domain.tld;
       ssl on;
       ssl_protocols TLSv1.2;
       ssl_certificate /etc/letsencrypt/live/votrenomde.domaineg/fullchain.pem;
       ssl_certificate_key /etc/letsencrypt/live/votrenomde.domaine/privkey.pem;
       ssl_dhparam /etc/ssl/private/dhparams.pem;
       ssl_ecdh_curve secp384r1;
       ssl_prefer_server_ciphers on;
       ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
       
       location / {
               proxy_pass https://my.base.service.ip/;
       }
}

Intégration Proxmox

On génère :

certbot certonly -d proxmox.domain.tld --rsa-key-size 4096

On supprime les certificats originaux :

rm -rf /etc/pve/local/pve-ssl.pem
rm -rf /etc/pve/local/pve-ssl.key
rm -rf /etc/pve/pve-root-ca.pem

On remplace :

ln -s /etc/letsencrypt/live/proxmox.domain.tld/fullchain.pem /etc/pve/local/pve-ssl.pem
ln -s /etc/letsencrypt/live/proxmox.domain.tld/privkey.pem /etc/pve/local/pve-ssl.key
ln -s /etc/letsencrypt/live/proxmox.domain.tld/chain.pem /etc/pve/pve-root-ca.pem

On redémarre les services pour valider :

service pveproxy restart
service pvedaemon restart

Voir Wiki Proxmox

Zimbra

Microsoft IIS

SMTP Postfix

On édite :

nano /etc/postfix/main.cf
smtpd_tls_cert_file = /etc/letsencrypt/live/my.domain.tld/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/my.domain.tld/privkey.pem

On redémarre le service :

service postfix restart

IMAP Dovecot

On édite :

nano /etc/dovecot/conf.d/10-ssl.conf
ssl_cert = </etc/letsencrypt/live/my.domain.tld/fullchain.pem
ssl_key = </etc/letsencrypt/live/my.domain.tld/privkey.pem

On redémarre le service :

service dovecot restart

Client LE alternatif : dehydrated

Bonus : DNS CAA

Pas encore disponible chez OVH
Dans la zone DNS, ajouter les entrées :

my.domain.tld. CAA 1 issue "letsencrypt.org"
my.domain.tld. CAA 1 iodef "mailto:me@domain.tld"

Bonus : récupérer manuellement l'expiration d'un certificat distant

echo | openssl s_client -servername <mon-server> -connect <mon-server>:443 2>/dev/null | openssl x509 -noout -issuer -subject -dates

Wildcards

Avec Certbot, un domaine par wildcard et ajout du root :

./certbot-auto --server https://acme-v02.api.letsencrypt.org/directory -d "libox.fr" -d "*.libox.fr" --preferred-challenges=dns --manual certonly

On peut rajouter comme docs :

  • system/linux/debian/4-lets-encrypt.txt
  • Dernière modification: 2020/06/19 20:55
  • (modification externe)