====== 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
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/
AllowOverride FileInfo AuthConfig Limit Options
Options +MultiViews +FollowSymLinks +IncludesNoExec -Indexes
Order allow,deny
Allow from all
#https :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
AllowOverride FileInfo AuthConfig Limit Options
Options +MultiViews +FollowSymLinks +IncludesNoExec -Indexes
Order allow,deny
Allow from all
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
Pour le fichier ''ssl.conf'', voir [[selfhosted:setup:5-lamp#apachessl|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 [[https://memo-linux.com/configurer-le-serveur-web-nginx-en-https-avec-letsencrypt-sous-debian-jessie/|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 ======
Via [[https://homeserver-diy.net/wiki/index.php?title=Utilisation_d%27Nginx_comme_reverse_proxy_avec_un_certificat_auto-sign%C3%A9,_Let%27s_Encrypt_et_un_chiffrement_fort]]
===== 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 [[https://pve.proxmox.com/wiki/HTTPS_Certificate_Configuration_(Version_4.x_and_newer)#Let.27s_Encrypt_using_acme.sh|Wiki Proxmox]]
====== Zimbra ======
https://wiki.zimbra.com/wiki/Installing_a_LetsEncrypt_SSL_Certificate
====== Microsoft IIS ======
https://www.abyssproject.net/2016/08/lets-encrypt-iis-10/
====== 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 =
On redémarre le service :
service dovecot restart
====== Client LE alternatif : dehydrated ======
* Source : https://github.com/lukas2511/dehydrated
* Article : https://blog.hbis.fr/2017/03/11/letsencrypt-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 -connect :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 :
* Tuto complet Certbot + wildcard + nombreux gestionnaires DNS : https://blog.blaisot.org/letsencrypt-wildcard-part1.html & https://blog.blaisot.org/letsencrypt-wildcard-part2.html
* Tuto complet Certbot + wildcard + OVH : https://inios.fr/let-s-encrypt-et-zone-ovh