Installation von Let’s Encrypt auf CentOS 7 mit Apache
Let’s Encrypt ist eine Zertifizierungsstelle, die kostenlose X.509-Zertifikate für Transport Layer Security (TLS) anbietet. In diesem Tutorial wird erläutert, wie man Let´s Encrypt SSL anhand des ACME Vorgang mit certbot durchführt, und Let’s Encrypt auf einem CentOS 7 Host mit Apache-Webserver implementiert.
Vorausgesetzt wird hier, das der Apache-Webserver bereits installiert ist, die Domain als Apache VirtualHost konfiguriert ist, und die Domain im DNS auflösbar ist, mit einem A-Record in der Forward-Zone dieser Domain, oder für IPv6 ein Quad-A-Record für den Server eingetragen ist. Weiter muss für das ACME Challenge der Server über Port 80 erreichbar sein.
Zur installation wollen wir root werden.
1 2 3 4 |
~]$ su - Password: Last login: Tue Jan 15 06:25:52 CET 2019 on pts/0 |
1 2 3 |
~]# yum -y install epel-release ~]# yum -y install mod_ssl python-certbot-apache |
Nun den Apache-Webserver neu starten.
1 2 |
~]# systemctl restart httpd |
Die Firewall für SSL mit dem Service Port 443 öffnen.
1 2 3 |
~]# firewall-cmd --add-service=https ~]# firewall-cmd --runtime-to-permanent |
Jetzt durch den certbot das SSL-Zertifikat generieren lassen.
1 2 |
~]# certbot --apache -d mydomain.com -d www.mydomain.com |
Die erste Domäne sollte die Basis Domain sein. In diesem Beispiel heißt sie mydomain.com, diese durch den tatsächlichen Domain-Name ersetzen.
Die Ausgabe des certbot sieht in etwa wie folgt aus.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
~]# certbot --apache -d mydomain.com -d www.mydomain.com Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator apache, Installer apache Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org Obtaining a new certificate Performing the following challenges: http-01 challenge for mydomain.com Waiting for verification... Cleaning up challenges Resetting dropped connection: acme-v02.api.letsencrypt.org Created an SSL vhost at /etc/httpd/conf.d/mydomain-ssl.conf Deploying Certificate to VirtualHost /etc/httpd/conf.d/mydomain-le-ssl.conf Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2 Redirecting vhost in /etc/httpd/conf.d/mydomain.conf to ssl vhost in /etc/httpd/conf.d/mydomain-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://mydomain.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=mydomain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/mydomain.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/mydomain.com/privkey.pem Your cert will expire on 2019-04-14. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. 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 |
Abschließend kann die URL getestet werden.
1 2 |
~]# curl -k https://mydomain.com |
Die URL im Browser abrufen und bei SSL Labs verifizieren.
1 2 |
https://www.ssllabs.com/ssltest/analyze.html?d=mydomain.com |
Das Let’s Encrypt Zertifikat ist 90 Tage gültig. Für die automatische Erneuerung des Zertifikats, erstellen wir ein neuen Cron-Job.
1 2 3 4 |
~]# crontab -e 0 0 * * 0 /usr/bin/certbot renew >> /var/log/certbot.log |
Das Zertifikat wird einmal in der Woche um Mitternacht zur Erneuerung überprüft.