• Applications
  • [Discussion] Certificat SSL signé et gratuit avec Let's Encrypt

Super !! Comme quoi, ça se joue à pas grand chose.

16 jours plus tard

Wonderfall Sous Apache 2.4 avec Quickbox cela serait conforme pour le module Strict Transport Security (HSTS) compatible nextcloud v11 ?:

<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
Header set X-Content-Type-Options nosniff
Header set X-XSS-Protection: 1; mode=block
Header set X-Robots-Tag: none
Header set X-Frame-Options: SAMEORIGIN
</IfModule> 

j'ai mis ceci en plus pour la redirection en http vers https :
Dans ce fichier

nano /etc/apache2/sites-enabled/000-default-le-ssl.conf
<VirtualHost *:80>
   ServerName votredomaine.fr
   Redirect permanent / https://votredomaine.fr/
</VirtualHost> 
<IfModule mod_ssl.c>
<VirtualHost *:443>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
Header set X-Content-Type-Options nosniff
Header set X-XSS-Protection: 1; mode=block
Header set X-Robots-Tag: none
Header set X-Frame-Options: SAMEORIGIN
</IfModule>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /srv/rutorrent/home/

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
SSLCertificateFile /etc/letsencrypt/live/votredomaine.fr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/votredomaine.fr/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
ServerName votredomaine.fr
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
</IfModule>

Voici le fichier (include):

nano /etc/letsencrypt/options-ssl-apache.conf
# Baseline setting to Include for SSL sites

SSLEngine on

# Intermediate configuration, tweak to your needs
SSLProtocol             TLSv1.2
SSLCipherSuite          EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
SSLHonorCipherOrder     on
SSLCompression          off

SSLOptions +StrictRequire

# Add vhost name to log entries:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common

#CustomLog /var/log/apache2/access.log vhost_combined
#LogLevel warn
#ErrorLog /var/log/apache2/error.log

# Always ensure Cookies have "Secure" set (JAH 2012/1)
#Header edit Set-Cookie (?i)^(.*)(;\s*secure)??((\s*;)?(.*)) "$1; Secure$3$4"

Pourtant j'ai toujours l'erreur sur Nextcloud v11: "L'en-tête HTTP "Strict-Transport-Security" n'est pas configurée à "15552000" secondes. Pour renforcer la sécurité nous recommandons d'activer HSTS comme décrit dans notre Guide pour le renforcement et la sécurité.", Apache 2.4 semble bien fonctionné en redémarrage et j'ai que le "A" en évaluation.

Sous nginx avec bonobox cela marchait "A+" et HSTS avec cette configuration.

Quelqu'un serait-il d'où vient le soucis ?

Pour HSTS tu n'as qu'à mettre ceci dans ton vhost

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

Tu peux aussi changer la durée.

Et pour LE :

/opt/letsencrypt/letsencrypt-auto certonly --apache --hsts --rsa-key-size 4096 --uir --renew-by-default -d upandclear.org -d www.upandclear.org

Ou pour Certbot :

./certbot-auto renew --hsts --rsa-key-size 4096 --uir

    Aerya j'ai réussi à avoir le "A+" déjà le module n'était pas actif :/ cela promet:

    sudo a2enmod headers

    j'ai retiré une ligne qui crée un souci "Header set X-XSS-Protection: 1; mode=block":

    <IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
    Header set X-Content-Type-Options nosniff
    Header set X-Robots-Tag: none
    Header set X-Frame-Options: SAMEORIGIN
    </IfModule>

    ma rsa-key-size était déjà en 4096 bits et l'erreur de nextloud à disparu "L'en-tête HTTP "Strict-Transport-Security" n'est pas configurée à "15552000" secondes. Pour renforcer la sécurité nous recommandons d'activer HSTS comme décrit dans notre Guide pour le renforcement et la sécurité." Donc cela semble résolu.

    6 jours plus tard

    hello, je voudrais renouveler mon certificat qui a expiré , j'arrete donc nginx, mais quand je tape:

    ./certbot-auto renew

    j'ai ceci:

    bash: ./certbot-auto: Aucun fichier ou dossier de ce type

    je pense que j'ai pas tout compris à coup sur, alors si quelqu'un pouvait m'éclairer, merci

    Salut

    faut être dans le bon répertoire ou ce trouve certbot ,test comme ça

    cd /tmp
    wget https://dl.eff.org/certbot-auto
    chmod a+x ./certbot-auto
    ./certbot-auto renew

    nickel chrome, tout roule! merci xavier

    en passant, c'est cette manip qu'il faudra que je fasse à chaque renouvellement de cetificat?

      Oui, tu peux mettre certbot en cron.

      allan84 Par contre je conseille plutôt de placer certbot dans /opt si tu veux faire un cron.

      merci à vous deux mais je le ferai manuellement la prochaine fois ne sachant pas faire ce que vous dites

        Ce que tu peux faire pour éviter de le télécharger chaque fois (car 90 jours après on sait plus où on a mis le fichier) ou être dans le bon répertoire pour le lancer.

        cd /tmp
        wget https://dl.eff.org/certbot-auto
        cp certbot-auto /usr/sbin/
        chmod 770 /usr/sbin/certbot-auto
        

        et le jour que tu dois le renouveler

        service nginx stop
        certbot-auto renew
        service nginx start

        ok merci me servira à coup sur

        allan84 https://certbot.eff.org/all-instructions/#debian-8-jessie-nginx

        Automating renewal
        The Certbot packages on your system come with a cron job that will renew your certificates automatically before they expire. Since Let's Encrypt certificates last for 90 days, it's highly advisable to take advantage of this feature. You can test automatic renewal for your certificates by running this command:

        certbot renew --dry-run

        Sinon => https://certbot.eff.org/docs/using.html#renewal

        merci Aerya mais franchement j'y comprends rien. j'ignore absolument ou on doit mettre cette commande que tu donnes au-dessus. je préfère faire le renouvelement manuellement

        Personnellement je trouve que c'est un peu galère de renouveler l'opération tous les 3 mois.
        Je ne sais pas si on peux juste appuyer sur un bouton ou crontab le truc 🙂

          jgalode
          Merci pour le partage. Je testerai prochainement.

          Beh... C'est prévu pour tourner en CRON en effet. Après faut savoir un minimum utiliser Linux mais ça fait partie des bases ce genre de job.