Skip to content

Let's Encrypt installieren

Verschoben Let's Encrypt
3 1 1.4k
  • Was ist Let's Encrypt?

    Let’s Encrypt (deutsch „Lasst uns verschlüsseln“) ist eine Zertifizierungsstelle, die Ende 2015 in Betrieb gegangen ist und kostenlose X.509-Zertifikate für Transport Layer Security (TLS) anbietet. Dabei ersetzt ein automatisierter Prozess die bisher gängigen komplexen händischen Vorgänge bei der Erstellung, Validierung, Signierung, Einrichtung und Erneuerung von Zertifikaten für verschlüsselte Websites.

    Quelle: de.wikipedia.org

    Ziel des Ganzen ist es, den Datentransport zwischen dem Client und dem Webserver zu verschlüsseln, so das unterwegs niemand die Daten mitlesen kann.

    Vorbereitung

    Bei meinem Serverumzug ist folgendes aufgefallen.

     Sep 29 14:22:27 amadeus nginx[1078]: nginx: [emerg] BIO_new_file("/etc/nginx/dhparams.pem") failed (SSL: error:02001002:system
    

    Nginx meckert über einen nicht vorhanden Schlüssel. Hmm, etwas googlen und fündig geworden.

    Man muss mittels openssl erstmal einen geheimen privaten Key erzeugen.

    root@amadeus /etc/letsencrypt # openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
    Generating DH parameters, 2048 bit long safe prime, generator 2
    This is going to take a long time
    ...........................................................................+...................................................................
    (gekürzt)
    

    Das erzeugt im angegebenen Verzeichnis einen 2048 Bit langen Schlüssel. Ganz ängstliche wählen 4096 Bit. Mit der Option "-aes256" kann man den Key auch noch mit einem Passwort verschlüsseln.

    Das File in den Ordner /etc/nginx kopieren und fertig. Ich habe da noch ein kleines Problem, das in der Konfiguration das File dhparams.pem heißt, das erzeugte File aber dhparam.pem. Vermutlich ein Tippfehler von mir, schau ich mir nochmal an. Vorerst habe ich die Datei einfach umbenannt.

    Installation

    Nach dem Hinweis meines Sysadmins 🙂 muss ich das hier noch ein wenig verfeinern.

    apt install letsencrypt
    

    Danach

    root@one /opt/letsencrypt # /etc/init.d/nginx stop
    [ ok ] Stopping nginx (via systemctl): nginx.service.
    root@one /opt/letsencrypt # letsencrypt certonly --standalone -d frank-mankel.org -d www.frank-mankel.org
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Plugins selected: Authenticator standalone, Installer None
    Obtaining a new certificate
    Performing the following challenges:
    http-01 challenge for frank-mankel.org
    http-01 challenge for www.frank-mankel.org
    Waiting for verification...
    Cleaning up challenges
    
    IMPORTANT NOTES:
     - Congratulations! Your certificate and chain have been saved at:
       /etc/letsencrypt/live/frank-mankel.org/fullchain.pem
       Your key file has been saved at:
       /etc/letsencrypt/live/frank-mankel.org/privkey.pem
       Your cert will expire on 2018-07-13. To obtain a new or tweaked
       version of this certificate in the future, simply run
       letsencrypt-auto again. To non-interactively renew *all* of your
       certificates, run "letsencrypt-auto renew"
     - If you like Certbot, please consider supporting our work by:
    
       Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
       Donating to EFF:                    https://eff.org/donate-le
    

    Das hat schon mal geklappt!!

    Hinweis

    Der Certbot kann je nach System entweder

    certbot-auto
    

    oder

    certbot
    

    heißen. Quelle: https://certbot.eff.org/docs/intro.html#installation

    Hier liegen die Zertifikate

    /etc/letsencrypt/live/frank-mankel.org
    

    Dort liegen jetzt folgende Files:

    root@one /etc/letsencrypt/live/frank-mankel.org # ls -l
    total 4
    lrwxrwxrwx 1 root root  40 Apr 14 15:15 cert.pem -> ../../archive/frank-mankel.org/cert1.pem
    lrwxrwxrwx 1 root root  41 Apr 14 15:15 chain.pem -> ../../archive/frank-mankel.org/chain1.pem
    lrwxrwxrwx 1 root root  45 Apr 14 15:15 fullchain.pem -> ../../archive/frank-mankel.org/fullchain1.pem
    lrwxrwxrwx 1 root root  43 Apr 14 15:15 privkey.pem -> ../../archive/frank-mankel.org/privkey1.pem
    -rw-r--r-- 1 root root 543 Apr 14 15:15 README
    

    Zertifikate in nginx einbauen

    nginx stoppen:

    /etc/init.d/nginx stop
    

    Meine alte nginx Datei OHNE https. Datei default

    server {
    if ($host != 'frank-mankel.org' ) {
    rewrite ^/(.*)$ http://frank-mankel.org/$1 permanent;
    }
    
        listen 80;
    
        server_name frank-mankel.org;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567;
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

    NEUE Datei mit https!!

    ### redirects http requests to https
    
    server {
        server_name  www.frank-mankel.org;
        rewrite ^(.*) http://frank-mankel.org$1 permanent;
    }
    
    
    
    server {
        listen 80;
        server_name frank-mankel.org;
        return 302 https://$server_name$request_uri;
    }
    
    ### the https server
    server {
        # listen on ssl, deliver with speedy if possible
        listen 443 ssl spdy;
    
        server_name frank-mankel.org;
    
    
        # change these paths!
        ssl_certificate /etc/letsencrypt/live/frank-mankel.org/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/frank-mankel.org/privkey.pem;
    
        # enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    
        # disables all weak ciphers
        ssl_ciphers 'AES128+EECDH:AES128+EDH';
    
        ssl_prefer_server_ciphers on;
    
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
    
            proxy_pass http://127.0.0.1:4567;  # no trailing slash
            proxy_redirect off;
    
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    

    Der Ganze http Verkehr wird nach https umgeleitet.

    Als allererstes strippen wir www aus dem Namen.

    if ($host != 'frank-mankel.org' ) {
     rewrite ^/(.*)$ http://frank-mankel.org/$1 permanent;
    }
    

    Der Rest entspricht der nginx Doku!

    Jetzt bauen wir das Zertifikat ein. Pfade anpassen.

    # change these paths!
        ssl_certificate /etc/letsencrypt/live/frank-mankel.org/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/frank-mankel.org/privkey.pem;
    

    Danach speichern und nginx wieder starten

    /etc/init.d/nginx start  
    

    Alles Testen und schauen ob alles funktioniert.

    Zertifikat erneuern

    Das Let's Encrypt Zertifikat läuft nur 90 Tage, danach muss es erneuert werden!

    Also legen wir uns einen crontab an

    crontab -e
    

    Wir fügen folgende Zeile hinzu.

     * 3  1 * * certbot -q renew
    

    Das war mein erster Versuch, das gibt aber einen Fehler. So lange nginx läuft, geht das nicht. Aber dafür kann man dem certbot Befehle mitgeben um nginx zu stoppen und zu starten. Das sieht dann so aus.

    * 3  1 * * certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
    

    Eine erfolgreiche Zertifikatsverlängerung sieht dann so aus.

    certbot renew --pre-hook "service nginx stop" --post-hook "service nginx start"
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    
    -------------------------------------------------------------------------------
    Processing /etc/letsencrypt/renewal/frank-mankel.org.conf
    -------------------------------------------------------------------------------
    Attempting to parse the version 0.23.0 renewal configuration file found at /etc/letsencrypt/renewal/frank-mankel.org.conf with version 0.10.2 of Certbot. This might not work.
    Cert is due for renewal, auto-renewing...
    Running pre-hook command: service nginx stop
    Renewing an existing certificate
    Performing the following challenges:
    tls-sni-01 challenge for frank-mankel.org
    tls-sni-01 challenge for www.frank-mankel.org
    Waiting for verification...
    Cleaning up challenges
    Generating key (2048 bits): /etc/letsencrypt/keys/0004_key-certbot.pem
    Creating CSR: /etc/letsencrypt/csr/0004_csr-certbot.pem
    
    -------------------------------------------------------------------------------
    new certificate deployed without reload, fullchain is
    /etc/letsencrypt/live/frank-mankel.org/fullchain.pem
    -------------------------------------------------------------------------------
    
    Congratulations, all renewals succeeded. The following certs have been renewed:
      /etc/letsencrypt/live/frank-mankel.org/fullchain.pem (success)
    Running post-hook command: service nginx start
    

    Erledigt 🙂

    Vielen Dank für eine tolle Anleitung zum Thema! Quelle: https://willy-tech.de/ssl-zertifikat-mit-lets-encrypt-erstellen/

  • Ich will das Ganze um eine Subdomain erweitern

    root@one /opt/letsencrypt # letsencrypt certonly --standalone -d frank-mankel.org -d www.frank-mankel.org -d forum.frank-mankel.org 
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Plugins selected: Authenticator standalone, Installer None
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    You have an existing certificate that contains a portion of the domains you
    requested (ref: /etc/letsencrypt/renewal/frank-mankel.org.conf)
    
    It contains these names: frank-mankel.org, www.frank-mankel.org
    
    You requested these names for the new certificate: frank-mankel.org,
    www.frank-mankel.org, forum.frank-mankel.org.
    
    Do you want to expand and replace this existing certificate with the new
    certificate?
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    (E)xpand/(C)ancel: E
    Renewing an existing certificate
    Performing the following challenges:
    http-01 challenge for forum.frank-mankel.org
    tls-sni-01 challenge for frank-mankel.org
    tls-sni-01 challenge for www.frank-mankel.org
    Waiting for verification...
    Cleaning up challenges
    
    IMPORTANT NOTES:
     - Congratulations! Your certificate and chain have been saved at:
       /etc/letsencrypt/live/frank-mankel.org/fullchain.pem
       Your key file has been saved at:
       /etc/letsencrypt/live/frank-mankel.org/privkey.pem
       Your cert will expire on 2018-10-17. To obtain a new or tweaked
       version of this certificate in the future, simply run
       letsencrypt-auto again. To non-interactively renew *all* of your
       certificates, run "letsencrypt-auto renew"
     - If you like Certbot, please consider supporting our work by:
    
       Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
       Donating to EFF:                    https://eff.org/donate-le
    
  • Wenn ihr alles richtig gemacht habt, dann könnt ihr Euer Zertifikat überprüfen lassen. Sollte dann so aussehen.

    0_1538314120455_index.jpeg

  • FrankMF FrankM hat am auf dieses Thema verwiesen
  • Podman & nftables

    Linux podman nftables linux
    1
    0 Stimmen
    1 Beiträge
    191 Aufrufe
    Niemand hat geantwortet
  • Debian 12 & fail2ban

    Linux debian linux fail2ban
    1
    0 Stimmen
    1 Beiträge
    143 Aufrufe
    Niemand hat geantwortet
  • pfSense - Release 2.7.2

    pfSense pfsense linux
    1
    1
    0 Stimmen
    1 Beiträge
    359 Aufrufe
    Niemand hat geantwortet
  • KDE neon 6.0

    Linux kde plasma6 linux
    2
    1
    0 Stimmen
    2 Beiträge
    330 Aufrufe
    FrankMF
    Heute mal in die bestehende Installation meine Intel ARC A580 GPU eingesteckt. Wollte mal schauen ob das gut klappt. Da die Treiber ja im Kernel vorhanden sind, habe ich keinerlei Probleme erwartet. Und so war es auch. Neustart und fertig. Im BIOS natürlich vorher umgestellt, das sie auch benutzt wird, habe ja einen AMD Prozessor mit eingebauter GPU im CPU-Sockel stecken. [image: 1709458279730-screenshot_20240303_101728.png] Die Wechselfunktion (oben links in der Ecke) um die virtuellen Desktops zu wechseln und zu bearbeiten ist richtig gut geworden. [image: 1709458292090-screenshot_20240303_101809-resized.png] Und auch ein Ärgernis auf meiner KDE Plasma Installation scheint weg zu sein. Wenn ich ein Programm zur Arbeitsfläche hinzugefügt hatte, wurde die Position immer irgendwann zurückgesetzt. Beispiel, Icon des Programmes rechts unten abgelegt. Irgendwann tauchte es dann in der normalen Ansicht (alphabetisch) sortiert, links oben, wieder auf. Sehr nerviger Bug.
  • FrOSCon 18

    Linux froscon linux opensource
    1
    0 Stimmen
    1 Beiträge
    121 Aufrufe
    Niemand hat geantwortet
  • NodeBB - Update auf v1.18.6

    NodeBB nodebb nodejs linux
    1
    1
    0 Stimmen
    1 Beiträge
    177 Aufrufe
    Niemand hat geantwortet
  • ZFS - Wichtige Befehle

    Linux zfs linux
    3
    0 Stimmen
    3 Beiträge
    1k Aufrufe
    FrankMF
    Heute mal drüber gestolpert, das es auch so was geben kann. root@pve2:~# zpool status pool: pool_NAS state: ONLINE status: Some supported and requested features are not enabled on the pool. The pool can still be used, but some features are unavailable. action: Enable all features using 'zpool upgrade'. Once this is done, the pool may no longer be accessible by software that does not support the features. See zpool-features(7) for details. scan: scrub repaired 0B in 00:20:50 with 0 errors on Sun Apr 13 00:44:51 2025 config: NAME STATE READ WRITE CKSUM pool_NAS ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 ata-WDC_WDS100T1R0A-68A4W0_230520800733 ONLINE 0 0 0 ata-WDC_WDS100T1R0A-68A4W0_230520801376 ONLINE 0 0 0 errors: No known data errors Was machen? Als erstes mal ein Backup angestoßen. Danach root@pve2:~# zpool get all pool_NAS | grep feature pool_NAS feature@async_destroy enabled local pool_NAS feature@empty_bpobj active local pool_NAS feature@lz4_compress active local pool_NAS feature@multi_vdev_crash_dump enabled local pool_NAS feature@spacemap_histogram active local pool_NAS feature@enabled_txg active local pool_NAS feature@hole_birth active local pool_NAS feature@extensible_dataset active local pool_NAS feature@embedded_data active local pool_NAS feature@bookmarks enabled local pool_NAS feature@filesystem_limits enabled local pool_NAS feature@large_blocks enabled local pool_NAS feature@large_dnode enabled local pool_NAS feature@sha512 enabled local pool_NAS feature@skein enabled local pool_NAS feature@edonr enabled local pool_NAS feature@userobj_accounting active local pool_NAS feature@encryption enabled local pool_NAS feature@project_quota active local pool_NAS feature@device_removal enabled local pool_NAS feature@obsolete_counts enabled local pool_NAS feature@zpool_checkpoint enabled local pool_NAS feature@spacemap_v2 active local pool_NAS feature@allocation_classes enabled local pool_NAS feature@resilver_defer enabled local pool_NAS feature@bookmark_v2 enabled local pool_NAS feature@redaction_bookmarks enabled local pool_NAS feature@redacted_datasets enabled local pool_NAS feature@bookmark_written enabled local pool_NAS feature@log_spacemap active local pool_NAS feature@livelist enabled local pool_NAS feature@device_rebuild enabled local pool_NAS feature@zstd_compress enabled local pool_NAS feature@draid enabled local pool_NAS feature@zilsaxattr disabled local pool_NAS feature@head_errlog disabled local pool_NAS feature@blake3 disabled local pool_NAS feature@block_cloning disabled local pool_NAS feature@vdev_zaps_v2 disabled local Das kommt von neuen Funktionen, die zu ZFS hinzugefügt wurden und bei Erstellung des Pools nicht vorhanden waren. Dann upgraden wir mal root@pve2:~# zpool upgrade pool_NAS This system supports ZFS pool feature flags. Enabled the following features on 'pool_NAS': zilsaxattr head_errlog blake3 block_cloning vdev_zaps_v2 Kontrolle root@pve2:~# zpool status pool: pool_NAS state: ONLINE scan: scrub repaired 0B in 00:20:50 with 0 errors on Sun Apr 13 00:44:51 2025 config: NAME STATE READ WRITE CKSUM pool_NAS ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 ata-WDC_WDS100T1R0A-68A4W0_230520800733 ONLINE 0 0 0 ata-WDC_WDS100T1R0A-68A4W0_230520801376 ONLINE 0 0 0 errors: No known data errors Features kontrollieren root@pve2:~# zpool get all pool_NAS | grep feature pool_NAS feature@async_destroy enabled local pool_NAS feature@empty_bpobj active local pool_NAS feature@lz4_compress active local pool_NAS feature@multi_vdev_crash_dump enabled local pool_NAS feature@spacemap_histogram active local pool_NAS feature@enabled_txg active local pool_NAS feature@hole_birth active local pool_NAS feature@extensible_dataset active local pool_NAS feature@embedded_data active local pool_NAS feature@bookmarks enabled local pool_NAS feature@filesystem_limits enabled local pool_NAS feature@large_blocks enabled local pool_NAS feature@large_dnode enabled local pool_NAS feature@sha512 enabled local pool_NAS feature@skein enabled local pool_NAS feature@edonr enabled local pool_NAS feature@userobj_accounting active local pool_NAS feature@encryption enabled local pool_NAS feature@project_quota active local pool_NAS feature@device_removal enabled local pool_NAS feature@obsolete_counts enabled local pool_NAS feature@zpool_checkpoint enabled local pool_NAS feature@spacemap_v2 active local pool_NAS feature@allocation_classes enabled local pool_NAS feature@resilver_defer enabled local pool_NAS feature@bookmark_v2 enabled local pool_NAS feature@redaction_bookmarks enabled local pool_NAS feature@redacted_datasets enabled local pool_NAS feature@bookmark_written enabled local pool_NAS feature@log_spacemap active local pool_NAS feature@livelist enabled local pool_NAS feature@device_rebuild enabled local pool_NAS feature@zstd_compress enabled local pool_NAS feature@draid enabled local pool_NAS feature@zilsaxattr enabled local pool_NAS feature@head_errlog active local pool_NAS feature@blake3 enabled local pool_NAS feature@block_cloning enabled local pool_NAS feature@vdev_zaps_v2 enabled local So, alle neuen Features aktiviert. Jetzt kann der Pool weiterhin seine Arbeit machen.
  • VSCodium

    Linux linux vscodium
    1
    1
    0 Stimmen
    1 Beiträge
    280 Aufrufe
    Niemand hat geantwortet