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

Il y a une commande qui permet de savoir combien de jours le certificat est encore valide ?

    fabb24 Oui le renew tout simplement. Il te dira qu'il ne le fait pas vu qu'il reste X jours.

    Excellent! Merci beaucoup!

    Adieu...heu StartSSL.

    Bonne année à tous! Longue vie à mondedie.

    Bonsoir à tous,

    Je me permets de faire appel à vous car, tout comme remonté par fabb24, je ne parviens pas à la relancer le service nginx après avoir modifié la conf.

    Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
    # systemctl status nginx -l
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
       Active: failed (Result: exit-code) since Mon 2017-01-16 23:01:29 CET; 5s ago
         Docs: man:nginx(8)
      Process: 29245 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
     Main PID: 1297 (code=exited, status=0/SUCCESS)
    
    Jan 16 23:01:29 yoz nginx[29245]: nginx: [emerg] BIO_new_file("/etc/nginx/ssl/dhparams.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/ssl/dhparams.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
    Jan 16 23:01:29 yoz nginx[29245]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Jan 16 23:01:29 yoz systemd[1]: nginx.service: control process exited, code=exited status=1
    Jan 16 23:01:29 yoz systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    Jan 16 23:01:29 yoz systemd[1]: Unit nginx.service entered failed state.

    Mes fichiers de conf sont édités de la manière suivante:

    /etc/nginx/nginx.conf

    user www-data;
    worker_processes auto;
    pid /var/run/nginx.pid;
    
    events {
        worker_connections 1024;
        use epoll; # gestionnaire d'évènements epoll (kernel 2.6+)
    }
    
    http {
        #Requete maximun par ip 
        limit_req_zone $binary_remote_addr zone=flood:10m rate=100r/s;
        limit_req zone=flood burst=100 nodelay; 
         
        #Connexions maximum par ip 
        limit_conn_zone $binary_remote_addr zone=ddos:10m;
        limit_conn ddos 100;
    
        include /etc/nginx/mime.types;
        default_type  application/octet-stream;
    
        access_log /var/log/nginx/access.log combined;
        error_log /var/log/nginx/error.log error;
    
        sendfile on;
        keepalive_timeout 15;
        keepalive_disable msie6;
        keepalive_requests 100;
        tcp_nopush on;
        tcp_nodelay off;
        server_tokens off;
    
        gzip on;
        gzip_comp_level 5;
        gzip_min_length 512;
        gzip_buffers 4 8k;
        gzip_proxied any;
        gzip_vary on;
        gzip_disable "msie6";
        gzip_types
            text/css
            text/javascript
            text/xml
            text/plain
            text/x-component
            application/javascript
            application/x-javascript
            application/json
            application/xml
            application/rss+xml
            application/vnd.ms-fontobject
            font/truetype
            font/opentype
            image/svg+xml;
    
        include /etc/nginx/sites-enabled/*.conf;
        include /etc/nginx/ssl/params.conf;
    }

    /etc/nginx/sites-enabled/rutorrent.conf

    server {
        listen 80 default_server;
        listen 443 default_server ssl http2;
        server_name mydomain.ovh;
    
        charset utf-8;
        index index.html index.php;
        client_max_body_size 10M;
    
        ssl_certificate /etc/letsencrypt/live/mydomain.ovh/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mydomain.ovh/privkey.pem;
    
        include /etc/nginx/conf.d/ciphers.conf;
    
        access_log /var/log/nginx/rutorrent-access.log combined;
        error_log /var/log/nginx/rutorrent-error.log error;
    
        error_page 500 502 503 504 /50x.html;
        location = /50x.html { root /usr/share/nginx/html; }
    
        auth_basic "seedbox";
        auth_basic_user_file "/etc/nginx/passwd/rutorrent_passwd";
    
        location = /favicon.ico {
            access_log off;
            log_not_found off;
        }
    
        ## début config accueil serveur ##
    
        location ^~ / {
            root /var/www/base;
            include /etc/nginx/conf.d/php.conf;
            include /etc/nginx/conf.d/cache.conf;
            satisfy any;
            allow all; 
        }
    
        ## fin config accueil serveur ##
    
        ## debut config rutorrent ##
    
        location ^~ /rutorrent {
            root /var/www;
            include /etc/nginx/conf.d/php.conf;
            include /etc/nginx/conf.d/cache.conf;
        }
    
        location ~ /\.svn {
            deny all;
        }
    
        location ~ /\.ht {
            deny all;
        }
    
        location ^~ /rutorrent/conf/ {
            deny all;
        }
    
        location ^~ /rutorrent/share/ {
            deny all;
        }
    
        ## fin config rutorrent ##
    
        ## config utilisateurs  ##
    
        location /YOZ {
            include scgi_params;
            scgi_pass 127.0.0.1:5001;
            auth_basic "seedbox";
            auth_basic_user_file "/etc/nginx/passwd/rutorrent_passwd_yoz";
        }
    
        location /cakebox/ {
            rewrite ^/cakebox(/.*)$ $1 break;
            proxy_pass http://127.0.0.1:81;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;
        }
    
        location /cakebox/yoz/ {
            alias /home/yoz/torrents/;
            add_header Content-Disposition "attachment";
            satisfy any;
            allow all;
        }
    }

    /etc/nginx/ssl/params.conf

    ssl_session_timeout 1d;
    ssl_session_cache shared:SSL:50m;
    ssl_session_tickets off;
    
    ssl_ecdh_curve secp384r1;
    
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA";
    
    ssl_prefer_server_ciphers on;
    
    add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    
    ssl_stapling on;
    ssl_stapling_verify on;
    
    ssl_trusted_certificate /etc/letsencrypt/live/mydomain.ovh/fullchain.pem;
    
    resolver 8.8.8.8;

    Avez-vous une idée de ce qui a pu m'échapper ? Quels doivent être les droits associés au dossier /etc/letsencrypt ?

    Merci d'avance

    Salut,

    /etc/nginx/ssl/dhparams.pem existe bien ?

    Bonsoir,

    Merci pour la réponse !

    Le fichier est bien présent oui

    /etc/nginx/ssl# ls -al
    total 8
    -rw-------  1 root root  424 Jan 16 19:08 dhparams.pem
    -rw-r--r--  1 root root  808 Jan 16 23:47 params.conf

    C'est une histoire de droits ?

    Salut

    sur le coup j'ai cru un probléme de droit mais non car chez moi pareil

     
    ls -al /etc/nginx/ssl/
    -rw-------  1 root root  424 janv. 15 21:59 dhparams.pem
    -rw-r--r--  1 root root 1391 janv. 15 21:56 server.crt
    -rw-r--r--  1 root root 1704 janv. 15 21:56 server.key
    

    sinon tu as modifier quoi comme conf?

    test un truc, enlève include /etc/nginx/ssl/params.conf; de ngnix.conf

    Bonsoir,

    Si ça n'est pas une question de droit ça devient embêtant..

    J'arrivais à avoir accès à ruttorent et à cakebox jusqu'à ce que je me lance dans l'ajout de certificat.

    Le service nginx ne se lance pas avec la config que j'ai donné, mais j'arrive néanmoins à avoir accès à l'interface de cakebox lorsque les lignes suivantes sont commentées dans le fichier de conf rutorrent.conf :

     #    listen 443 default_server ssl http2;
    
     #   ssl_certificate /etc/nginx/ssl/fullchain.pem;
     #   ssl_certificate_key /etc/nginx/ssl/privkey.pem;

    Côté ruttorent, la redirection vers https est faite automatiquement par mon navigateur (firefox) et cela malgré les lignes commentées.. J'obtiens une belle page d'erreur en retour :/.

    J'ai aussi tenté la réinstall de nginx en suivant les commandes données par ex sans grand succès.

    Quels fichiers restent à vérifier du coup ?

    Merci d'avance,

    Bonjour,

    Je suis surpris du chemin de ton certificat LetsEncrypt. Normalement, c'est de la forme :
    /etc/letsencrypt/live/nomdedomain/cert.pem

    Bonsoir à tous,

    Merci Nekukab pour cette remarque ! J'avais volontairement tenté de déplacer les fichier sous /etc/nginx/ssl pour voir si l'erreur persistait et ai oublié de le remettre par la suite..

    Après avoir remplacé /etc/nginx/ssl par /etc/letsencrypt/live/nomdedomain/, j'ai obtenu une erreur différente.

    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
       Active: failed (Result: exit-code) since Wed 2017-01-18 20:01:03 CET; 56s ago
         Docs: man:nginx(8)
      Process: 1669 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
      Process: 22509 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
      Process: 1672 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
     Main PID: 22512 (code=exited, status=0/SUCCESS)
    
    Jan 18 20:01:03 yoz nginx[1672]: nginx: [emerg] SSL_CTX_load_verify_locations("/etc/nginx/ssl/fullchain.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/nginx/ssl/fullchain.pem','r') erro...
    Jan 18 20:01:03 yoz nginx[1672]: nginx: configuration file /etc/nginx/nginx.conf test failed
    Jan 18 20:01:03 yoz systemd[1]: nginx.service: control process exited, code=exited status=1
    Jan 18 20:01:03 yoz systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    Jan 18 20:01:03 yoz systemd[1]: Unit nginx.service entered failed state.

    J'ai alors enlevé le include /etc/nginx/ssl/params.conf; de ngnix.conf et depuis ça fonctionne !!

    Du coup, la configuration donnée dans le tuto est incorrecte ?

      snivel
      Salut
      je t’avais dit de l’enlever. 😉
      "test un truc, enlève include /etc/nginx/ssl/params.conf; de ngnix.conf" car cher moi je l'avais pas pour une config standard .
      en faite cette ligne et deja dans /etc/nginx/conf.d/ciphers.conf
      et pour le tuto il est bon mais cest configurer différemment par rapport au tuto que tu as suivi pour ngnix

      Bonsoir,

      Erreur de ma part. J'avais bien enlevé la ligne, mais remise après avoir obtenu la même erreur au restart du service.

      Merci de vos conseils 🙂

      Tant mieux si tout roule maintenant !

      11 jours plus tard

      Bonjour,
      Sur mon dédié je souhaite avoir deux sous-domaines, l'un destiné à la seedbox et un second pour un petit Owncloud. Je suis parvenu à appliquer un certificat au premier sous-domaine mais le second destiné à Owncloud ne fonction pas. Lorsque je lance la génération du certificat via let's encrypt j'obtiens l'erreur suivante alors qu'il est bien déclaré chez mon hébergeur.

      IMPORTANT NOTES:
      - The following errors were reported by the server:

      Domain: www.XXXX.XXXXX.tk
      Type: connection
      Detail: DNS problem: NXDOMAIN looking up A for
      www.XXXX.XXXXX.tk

      To fix these errors, please make sure that your domain name was
      entered correctly and the DNS A record(s) for that domain
      contain(s) the right IP address. Additionally, please check that
      your computer has a publicly routable IP address and that no
      firewalls are preventing the server from communicating with the
      client. If you're using the webroot plugin, you should also verify
      that you are serving files from the webroot path you provided.

      Je vous remercie par avance pour tout vos conseils !!

        Oui ils le sont bien. Je suppose que c'est une erreur au sein du paramétrages du serveur, mais je ne vois pas quoi exactement ..

        Il t'indique que tu as un probleme au niveau d'une ligne : Detail: DNS problem: NXDOMAIN looking up A for

        Cherche la ligne avec la déclaration de ton sous domaine car il ne semble pas le trouver.
        Si tu as paramétré ton sous domaine dans ton interface de ton hébergeur, il faut aller vérifier que tu as bien correctement saisi les champs. Sinon, c'est sur ton serveur avec le service bind9 ou bind.

          NOnoS C'est probablement au niveau du service bind9 car tout le reste paraît correctement configuré.
          Je parviens à générer un certificat pour sousdomaine.domaine.tld mais pas pour www.sousdomaine.domaine.tld

          PS : Lorsque je fais un nslookup il m'indique que le sous-domaine en question est carrément inexistant

          6 jours plus tard

          Bonjour !

          Alors j'ai suivis le tuto et à l'étape d'obtention des certificats j'ai ce message d'erreur :

          • The following errors were reported by the server:
            Domain: monnomdedomain.ovh
            Type: unauthorized
            Detail: Incorrect validation certificate for TLS-SNI-01 challenge.
            Requested
            d1c7b08f9b8acddf10444c686ef38f37.c2e64c7b740c92b8797ee911fea6baaa.acme.invalid
            from monadresseipserveur:443. Received 4 certificate(s), first certificate
            had names "mailconfig.ovh.net, www.mailconfig.ovh.net"
            To fix these errors, please make sure that your domain name was
            entered correctly and the DNS A record(s) for that domain
            contain(s) the right IP address.

          Ce que j'ai du mal a saisir, c'est que mon nom de domaine est bien déclaré sous Ovh comme indiqué dans les annexes de la "seedbox pour les nuls" installés avec le script Ex-Rat. je n'ai d'ailleurs aucun sous pour accéder à mon rutorrent/sickrage/cakebox de cette manière.

          J'ai parcours la conversation de ce thread et vu qu'on pouvait vérifier si les DNS étaient bien déclarés en utilisant https://dnschecker.org/ ce que j'ai fait et ils le sont correctement. Merci d'avance pour vos conseils.

          Bon j'ai avancé dans mon problème, j'ai pu obtenir les certificats et j'ai bien vérifiés qu'ils étaient présents pour mon site dans /etc/letsencrypt/live/.

          Ensuite je pense que là où ça coince c'est dans la config du rutorrent.conf, je m'explique j'ai essayé plein de choses, mais aucune ne me permettaient de redémarrer mon service nginx. J'avais systématiquement le droit a une erreur. Est-ce que qqn aurait la gentillesse de me montrer le sien ? Au moins pour la partie "server" s'il vous plait, car je pense que ma syntaxe ne doit pas être la bonne ?