73 lines
2.3 KiB
Markdown
73 lines
2.3 KiB
Markdown
# SSL
|
|
|
|
## LetsEncrypt
|
|
|
|
⚠️ l'accès à l'api Let's Encrypt étant limité en nombre de requète, on se contentera de générer des certificats de test.
|
|
|
|
### Prérequis
|
|
|
|
La configuration dns doit permettre de résoure le nom de notre serveur ( liaX.formation.opendoor.fr )
|
|
|
|
### Installation du client
|
|
|
|
Installer le paquet _certbot_ (depuis les dépôts EPEL).
|
|
```bash
|
|
dnf install -y certbot
|
|
```
|
|
|
|
### Procéder à la demande de certificat
|
|
|
|
```bash
|
|
certbot certonly --test-cert --webroot --webroot-path /var/www/html -d lia1.formation.opendoor.fr
|
|
```
|
|
|
|
### Vérifier
|
|
|
|
```bash
|
|
certbot certificates
|
|
...
|
|
ls -l /etc/letsencrypt/live/
|
|
```
|
|
|
|
### Utiliser les certificats
|
|
|
|
Utiliser les directives apache SSLCertificateFile et SSLCertificateKeyFile
|
|
```bash
|
|
SSLEngine on
|
|
SSLCertificateFile /etc/letsencrypt/live/lia1.formation.opendoor.fr/fullchain.pem
|
|
SSLCertificateKeyFile /etc/letsencrypt/live/lia1.formation.opendoor.fr/privkey.pem
|
|
SSLProtocol +TLSv1.2
|
|
SSLCompression off
|
|
SSLHonorCipherOrder on
|
|
SSLCipherSuite TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDH
|
|
Header always set Strict-Transport-Security "max-age=63072000;
|
|
Header set Content-Security-Policy "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'"
|
|
Header set X-Content-Type-Options "nosniff"
|
|
Header set X-Frame-Options "SAMEORIGIN"
|
|
Header set X-XSS-Protection "1; mode=block"
|
|
```
|
|
|
|
### Vérifier
|
|
|
|
En allant sur https://liaX.formation.opendoor.fr/ on doit obtenir malgré tout un avertissement de sécurité.
|
|
|
|
Cependant en examinant le certificat, on constate qu'il provient de l'organisation _(STAGING) Let's Encrypt_
|
|
|
|
|
|
### Configurer le renouvellement automatique du certificat
|
|
|
|
Créer une tâche planifiée permettant d'éxécuter une fois par semaine la commande _certbot renew_ en root
|
|
```bash
|
|
cat > /etc/cron.d/letsencrypt <<EOF
|
|
00 01 * * 6 root /usr/bin/certbot renew
|
|
EOF
|
|
```
|
|
|
|
Créer le script /etc/letsencrypt/renewal-hooks/post/apache.sh avec le contenu suivant:
|
|
```bash
|
|
#! /bin/bash
|
|
/bin/systemctl reload httpd
|
|
```
|
|
|
|
Le rendre exécutable. Il sera lancé à chanque renouvellement de certificat, permettant une prise en compte immédiate par apache du nouveau certificat.
|