Lets Encrypt!
Schon gesehen? https://fipsbox.spdns.de schaut doch einfach besser aus als http://fipsbox.spdns.de
HowTo:
So zum Beispiel koennte man sich selbst einen privaten Schluessel und Zertifikat erstellen:
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout example.key -out example.crt -subj "/CN=example.com" -addext "subjectAltName=DNS:example.com,DNS:www.example.net,IP:10.0.0.1"
Aber mit einem selbst erstelltem Zertifikat kommt man auch nicht weit; jeder moderne Browser
warnt vor solch einer verschluesselten Seite. Also muss ein offizielles Zertifikat her.
Kostenfreie X.509-Zertifikate für TLS (Transport Layer Security) gibt es bei letsencrypt.org.
Bei Linux hilft dir certboot bei der Beantragung und Auffrischung des Zertifikats. Hier in kurz
die wichtigsten Zeilen fuer die Konsole (Webserver ist hier ein lighttpd):
Aus https://certbot.eff.org/lets-encrypt/ubuntufocal-other
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo systemctl stop lighttpd.service
sudo certbot certonly --standalone
sudo systemctl start lighttpd.service
Im Ordner /etc/letsencrypt/live/ finden sich dann die notwendigen Dinge.
Das Pemfile erzeugt man als Root daraus so:
cat cert.pem privkey.pem > web.pem
Der relevante Teil der Konfiguration in /etc/lighttpd/lighttpd.conf kann dann so aussehen:
$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/letsencrypt/live/fipsbox.spdns.de/fullchain.pem"
ssl.privkey = "/etc/letsencrypt/live/fipsbox.spdns.de/privkey.pem"
}
Wenn man Port 80 (HTTP) Anfragen automatisch umleiten moechte, noch folgendes:
$SERVER["socket"] == ":80" {
$HTTP["host"] =~ "(.*)" {
url.redirect = (
"^/(.*)" => "https://%1/$1"
)
}
}
Zertifikat erneuern:
certbot renew --dry-run
certbot renew
Geschickter Neustart von Lighttpd:
sudo systemctl reload-or-restart lighttpd.service
Sehr hilfreich sind auch folgende Checks:
sudo lighttpd -t -f /etc/lighttpd/lighttpd.conf
sudo lighttpd -tt -f /etc/lighttpd/lighttpd.conf
cd /etc/lighttpd/
sudo lighttpd -tt -f lighttpd.conf
sudo systemctl stop lighttpd.service
sudo certbot renew --dry-run
sudo certbot renew
sudo systemctl reload-or-restart lighttpd.service