Ein Zertifikat von Let’s Encrypt

Von Let’s Encrypt lässt sich kostenlos ein SSL Zertifikat erstellen, welches ca. 18 Wochen gültig ist.

Man könnte sich fragen, ob das nicht der Sinn eines Zertifikats untergräbt, wenn ich für eine x-beliebige Domain ein Zertifikat bekomme.

Nun das ist okay, weil:

  1. der Rechner auf dem das Zertifikat läuft braucht einen gültigen DNS Eintrag (Das kann nur der Domaininhaber erstellen).
  2. der Rechner auf eine Anfrage des letsencypt Rechners richtig antworten muss, über ein Port 80 Skript (d.h da darf dann für einen Moment kein Apache/nginx laufen). Das kann nur der Eigentümer des Rechners sicher stellen.

Certbot

Früher ging es über Scripte von letsencrypt nun ist Certbot dafür zuständig..

Zuerst wird das System aktualisiert:

apt update
apt dist-upgrade

# Certboot installieren
apt install certbot

Los gehts (nginx ist an)

certbot certonly --standalone --rsa-key-size 4096 -d sub1.kuntner.de -d sub2.kuntner.de 
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): peter@kuntner.de

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for sub1.kuntner.de
http-01 challenge for sub2.kuntner.de
Cleaning up challenges
Problem binding to port 80: Could not bind to IPv4 or IPv6.

IMPORTANT NOTES:
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

nginx aus: service nginx stop

dann nochmal:

ertbot certonly --standalone --rsa-key-size 4096 -d sub1.kuntner.de -d sub2.kuntner.de 
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 sub1.kuntner.de
http-01 challenge for sub2.kuntner.de
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/sub1.kuntner.de/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/sub1.kuntner.de/privkey.pem
   Your cert will expire on 2020-06-18. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot 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 noch in das nginx File eintragen:

ssl_certificate /etc/letsencrypt/live/sub1.kuntner.de/fullchain.pem
ssl_certificate_key /etc/letsencrypt/live/sub1.kuntner.de/privkey.pem

Nginx neu starten:

service nginx start

Nun kann das neue Zertifikat im Browser angesehen werden.

Und ein Cronjob ist auch gleich angelegt, siehe:

cat /etc/cron.d/certbot

Fertig!!