Outils pour utilisateurs

Outils du site


article:linux:web_server_-_https_grade_a

Web server - HTTPS grade A

Date: 2022 Installation faite sur Debian 11

La configuration restreint les navigateurs utilisables - Internet Explorer 11* - Chrome 70 - Firefox 63

Objectif de cette article: Obtenir un serveur répondant en HTTPS from scratch avec un grade A+

Pré-requis:

Debian 11 (Voir cet article)

Note: On partira d'un serveur vierge avec uniquement le package apache2 d'installé apt install apache2 -y

Activation SSL sur Apache2

Il est nécessaire d'activer l'écoute sur le protocol 443 dans le fichier /etc/apache2/ports.conf. Le port 80 doit rester ouvert pour la négociation du certificat

  1. # /etc/apache2/ports.conf
  2. Listen 80
  3. Listen 443

Quelques mods à activer:

  1. a2enmod ssl
  2. a2enmod headers
  3. a2enmod http2
  • Liste à pucemod_ssl: Active la gestion du SSL/TLS
  • mod_headers: Personnalisation des en-têtes HTTP. Il sera utilisé pour informer le navigateur d'utiliser exclusivement HTTPS
  • http2: Plus rapide que HTTP/1.1, élimite d'anciens protocols de sécurité obsolète

Certbot

Source: https://certbot.eff.org/instructions?ws=apache&os=debianbuster

  1. # Installation de snapd
  2. apt install snapd
  3. snap install core
  4. snap refresh core
  5.  
  6. # Installation de certbot
  7. snap install --classic certbot
  8. ln -s /snap/bin/certbot /usr/bin/certbot
  9.  
  10. # On configure Let's Encrypt pour notre serveur:
  11. certbot --apache

✅ A partir d'ici, notre site devrait être en HTTPS certifié Let's Encrypt avec une configuration déjà correct faite par Certbot

Le renouvellement se fait automatiquement, il y a un timer dans systemd. Il peut être simulé (dry-run) avec cette commande: certbot renew –dry-run

Modifications constatée dans la configuration Apache2:

/etc/apache2/sites-enabled/<ssl-conf>.conf

  1. <VirtualHost *:443>
  2. # ...
  3. SSLEngine on
  4.  
  5. SSLCertificateFile /etc/letsencrypt/live/httpslabs.gh3.be/fullchain.pem
  6. SSLCertificateKeyFile /etc/letsencrypt/live/httpslabs.gh3.be/privkey.pem
  7. Include /etc/letsencrypt/options-ssl-apache.conf
  8. # ...
  9. </VirtualHost>

Amélioration de la sécurité

Source: https://ssl-config.mozilla.org/

On se base sur une configuration “moderne” proposé par Mozilla

Redirection HTTP vers HTTPS.

Note: Cette manipulation n'est pas idéale car du man-in-the-middle est toujours possible le temps de la redirection vers HTTPS

Note2: Le port 80 ne peut pas être fermé car (historiquement ?) le fichier .well-known-challenge utilisé par Let's Encrypt passe par HTTP

/etc/apache2/sites-enabled/<http-conf>.conf

  1. <VirtualHost *:80>
  2. # ...
  3. RewriteEngine On
  4. RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/
  5. RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
  6. # ...
  7. </VirtualHost>

/etc/apache2/sites-enabled/<https-conf>.conf

  1. <VirtualHost _default_:443>
  2. # ...
  3.  
  4. # Activation de HTTP/2, rétrocompatibilité vers HTTP/1.1 si besoin (mod_http2
  5. Protocols h2 http/1.1
  6.  
  7. # Activation du HTTP Strict Transport Security (mod_header)
  8. Header always set Strict-Transport-Security "max-age=63072000"
  9. # ...
  10. </VirtualHost>
  11.  
  12. # OCSP Stapling - https://fr.wikipedia.org/wiki/Agrafage_OCSP
  13. SSLUseStapling On
  14. SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"

Modification du chiffrement

On a remarqué précédemment que Certbot a créé un fichier de configuration des options SSL, on modifiera là dedans.

/etc/letsencrypt/options-ssl-apache.conf

  1. # ...
  2. # SSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
  3. SSLProtocol TLSv1.2 TLSv1.3
  4. #SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
  5. SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
  6. # ...

2 changements ici :

  • Support de TLSv1.2 et TLSv1.3
    Note: curl 7.83.1 ne supporte pas TLSv1.3
    Note2: Internet Explorer 11 ne supporte pas TLSv1.3
    https://caniuse.com/tls1-3
  • Désactivation des protocoles DHE-RSA-AES128-GCM-SHA256 et DHE-RSA-AES256-GCM-SHA384
    DH (Diffie Hellman) est déprécié par rapport à Eliptic Curve Diffie-Hellman (ECDH)
article/linux/web_server_-_https_grade_a.txt · Dernière modification : de Gary

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

GH3.BE WIKI 2025