aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2016-09-30 03:36:02 +0200
committerDavid Runge <dave@sleepmap.de>2016-09-30 03:36:02 +0200
commitaa96b26755f1e5747ed4f299752d85fd1cb31fa4 (patch)
tree23aac612a818e732a9a6900d36dba1d8fed6032f
parent8e37f51b8fc89243ec747e66b9cc2d4881de5b2c (diff)
downloadsleepmap-aa96b26755f1e5747ed4f299752d85fd1cb31fa4.tar.gz
sleepmap-aa96b26755f1e5747ed4f299752d85fd1cb31fa4.tar.bz2
sleepmap-aa96b26755f1e5747ed4f299752d85fd1cb31fa4.tar.xz
sleepmap-aa96b26755f1e5747ed4f299752d85fd1cb31fa4.zip
content/blog/201609-letsencrypt.rst: Finished article about letsencrypt with configuration examples and recommendations... what a monster.
-rw-r--r--content/blog/201609-letsencrypt.rst720
1 files changed, 714 insertions, 6 deletions
diff --git a/content/blog/201609-letsencrypt.rst b/content/blog/201609-letsencrypt.rst
index a4ec1d6..a3453ac 100644
--- a/content/blog/201609-letsencrypt.rst
+++ b/content/blog/201609-letsencrypt.rst
@@ -1,9 +1,9 @@
Let's encrypt it all
####################
-:date: 2016-09-28 20:00
-:modified: 2016-09-29 20:00
-:tags: archlinux, letsencrypt, openssl
+:date: 2016-09-29 20:00
+:modified: 2016-09-30 04:00
+:tags: acme, archlinux, certbot, certificate, dovecot, hidden service, letsencrypt, nginx, openssl, owncloud, postfix, prosody, roundcube, security, ssl, systemd, tls, vpn
:category: admin
:slug: lets-encrypt-it-all
:summary: A short review on half a year of using |website-letsencrypt| for my services.
@@ -12,6 +12,8 @@ Let's encrypt it all
| For a couple of months now I have been using |website-letsencrypt| to generate free and valid certificates for all the services I run.
| In many places the free |wiki-certificate_authority| (short CA) has spread like wild-fire. From small to large scale services, many adopted it and |blog-letsencrypt-1_million_certificates|.
| As a visitor to this website you have probably noticed the small green lock sign next to the address bar. The certificate used for this website is accepted to be valid by your browser (and also by your operating system).
+| If you're up for some background knowledge, just read on. If you're up for some hands-on technical stuff, `jump right on to the howto </2016/lets-encrypt-it-all/#letsencrypt-howto>`_.
+| Just note: This is a veeeeeeery long article in any case.
|
Certificate Authority
@@ -37,10 +39,10 @@ More Flaws
| Well... it will come to no surprise: |blog-turktrust_fiasko| and will happen (again).
| In a way this would also be a perfect time to ask yourself, if encrypted traffic is all that secure after all. A little paranoia never hurt.
|
-| The certificates with which the CAs sign other certificates and thereby *trust* them are called **root certificates** and are usually shipped by your operating system and/or your web browser. These bundles are used by all applications that understand encrypted traffic to check whether the connection they are about to make is trusted by a CA.
+| The certificates with which the CAs sign other certificates and thereby *trust* them are called *root certificates* and are usually shipped by your operating system and/or your web browser. These bundles are used by all applications that understand encrypted traffic to check whether the connection they are about to make is trusted by a CA.
| Now, there is no way of telling whether your CA bundle is sufficient or harmful, but at some point you have to trust your operating system. You do trust your operating system, don't you? Well, |news-microsoft_certificate_blacklist|.
| To circumvent this flaw in turn, Google and Mozilla introduced |wiki-certificate_pinning| in their browsers, which can detect fraudulent certificates for some domains by checking against checksums (derived from a |wiki-hash_function|) of the root certificate with which these domains are signed. These checksums (or sometimes called *hashes*) are shipped with the browser, which should make you wonder, if you can trust those either.
-| If you learned more about how this all works, you would probably consider moving to the woods far away from all this.
+| Sometimes I think, that the more one learns about the topic, the further one wants to move into the woods...
|
Self-sign
@@ -63,15 +65,601 @@ Encrypt the interwebz
| While self-signed and |website-cacert| certificates were becoming increasingly limiting and the sometimes high costs of buying a trusted certificate kept many from encrypting their traffic all together, the services *certified* by the usual CAs on the other hand stood in the light of false pretense to be *more secure* than the formerly named.
| |website-letsencrypt| has indeed come to restore the balance and free what should be free: Encrypted traffic.
| By issuing |wiki-intermediate_certificate|, which were cross-signed by |website-identrust|, |website-letsencrypt| is able to sign and thereby trust certificates it deems valid according to its |github-letsencrypt| validation system.
+| Their system is fully automated (implementing |wiki-acme|), easy (and in many ways) to use and doesn't suffer from the above mentioned pitfalls of the usual validation process.
|
Using letsencrypt
_________________
-| Their software is by now packaged for all major Linux distributions (and as a matter of fact, the Internet runs on Linux), so acquiring a valid certificate for your website has become so easy, it's insane.
+
+|letsencrypt-howto|
+
+| The |website-letsencrypt| software bundle is by now packaged for all major Linux distributions (and as a matter of fact, the Internet runs on Linux), so acquiring a valid certificate for your website has become so easy, it's insane.
| Let me tell you about how I do things on |website-archlinux| on this very server.
+| Although |website-letsencrypt| lets you freely handle the |wiki-acme| handshake yourself (if you want to do it manually or with |website-letsencrypt_acme_clients|), the community around it wrote a |website-python| based piece of software, that does just that. It's called |website-certbot| .
+| While some may argue its backward-compatibility is just dangerous, one could also argue the other way round: Unsecured webservers, running super old |website-python| versions, because their admins can't or won't update, is very dangerous.
+| In any case: Every sofware has bugs (some more severe than others), but those are also more likely to get fixed faster, the more people stumble upon them.
+| A unifying piece of software such as |website-certbot| is very useful and eases the overall spreading of |website-letsencrypt| .
+| Nonetheless, if you're able to do the |wiki-acme| challenge manually and it makes sense in your scenario, you might want to consider that.
+|
+
+certbot
+-------
+| |website-archlinux| has |website-certbot| in its repositories, so just install the latest version and all of its dependencies:
+
+ .. code:: bash
+
+ pacman -Sy certbot
+
+| Now would be a good time to have a look at |eff-certbot-nginx-howto| about |website-nginx| in conjunction with |website-certbot|.
+| |website-archlinux| of course also has a very |wiki-arch-letsencrypt| on the topic in its wiki.
+| At this point I am assuming |website-nginx| is already installed, configured for non-encrypted service and we want to generate certificates for the following domains: **www.domain.tld**, **domain.tld**, **cloud.domain.tld**, **www.cloud.domain.com**, **mail.domain.tld**, **www.mail.domain.tld** (using |wiki-san|).
+| Currently the certbot plugin for |website-nginx| is still experimental, so I will refrain from using it and use the webroot method instead.
+|
+
+nginx preparation
+-----------------
+| Let us have a look at how to configure |website-nginx|, so it will be prepared for the |wiki-acme| challenge.
+|
+
+Snippets
+++++++++
+
+* we require a directory (*.well-known/acme-challenge/*), that is writable by |website-certbot| (*root*) to place a challenge response on each domain
+* the directory must be servable (readable) by |website-nginx| (usually running with the user and group *http*)
+
+| As the directory can be the same for all the challenges on your server, you can of course just create one and redirect all requests from the outside to it. We will use */srv/http/letsencrypt/* for it and define a configuration block, that we can include anywhere we need it.
+|
+
+* */etc/nginx/letsencrypt-challenge.conf*
+
+ .. code:: nginx
+
+ location ~ /\.well-known/acme-challenge {
+ root /srv/http/letsencrypt;
+ default_type "text/plain";
+ }
+
+| This will tell nginx to look inside of */srv/http/letsencrypt* for requests to *./well-known/acme-challenge* on a domain, where we include this.
+|
+| The following short example is an overview of */etc/nginx/nginx.conf*. Yours might look different and this one is here for demonstrational purposes only!
+| Anyhow, I like to separately include the configuration for the different subdomains/domains here, so they will not get mixed up and it will be easier to add or disable functionality.
+|
+
+* */etc/nginx/nginx.conf*
+
+ .. code:: nginx
+
+ worker_processes auto;
+ error_log /var/log/nginx/error.log;
+ events {
+ worker_connections 1024;
+ }
+ http {
+ include mime.types;
+ default_type application/octet-stream;
+ gzip on;
+ sendfile on;
+ keepalive_requests 55;
+ keepalive_timeout 55;
+ # pelican blog
+ include domain.conf;
+ # ownCloud
+ include cloud.domain.conf;
+ # roundcube mail interface available only through VPN
+ include mail.domain.conf;
+ }
+
+| The initial configuration already shows, that we now have three services that will need to be covered by the certificate, which we want to get. The |website-roundcube| webmail service I picked for demonstrational purposes as a hidden service. This is not meant to badmouth their security, but to show that you can hide your service behind a :abbr:`VPN (Virtual Private Network)`, if you choose to.
+| To achieve something like that, you can use the |website-nginx| geo plugin. When you setup a VPN infrastructure, this will lead to you having a separate connection to your server within a |wiki-private_network|. For the sake of simplicity let us assume your server will have **172.16.0.1** and your client computer **172.16.0.2** as IPs in this setup.
+| On your server you can now explicitely look for the correct client and allow or deny access. Another block for the |website-nginx| configuration can be used to let you include this in your domain configurations:
+|
+
+* */etc/nginx/geoblock.conf*
+
+ .. code:: nginx
+
+ geo $is_allowed{
+ default 0;
+ 172.16.0.2 1;
+ }
+
+| Here we define a variable called *is_allowed*, which initially defaults to 0. If the request to your server is coming from the IP **172.16.0.2** *is_allowed* will be set to 1.
+| **Note**: Add this snippet to your hidden service's configuration file right at the top!
+|
+| There is one downside to this though, if you choose to have a |website-letsencrypt| certificate for the hidden service: You have to specify an extra check, that excludes calls to *.well-known/acme-challenge* from the geo block and makes it publicly accessible.
+| For that to happen you can define another block for multiple inclusion.
+|
+
+* */etc/nginx/letsencrypt-request-check.conf*
+
+ .. code:: nginx
+
+ if ($request_uri ~ \.well-known/acme-challenge) {
+ set $is_allowed 1;
+ }
+ if ($is_allowed = 0){
+ return 301 https://domain.tld$request_uri;
+ }
+
+| This snippet will set the previously introduced variable *is_allowed* to 1, if the request was correct and will permanently redirect to the main website otherwise.
+| As it makes sense to have https enabled on all of your services, the permanent redirect is added to this configuration snippet. You could also separate it out if you like.
+| **Note**: You must include *letsencrypt-request-check.conf* **after** *geoblock.conf*, but **before** *letsencrypt-challenge.conf*!
+|
+| You will have to include the above snippets in your configuration for each of your subdomains/domains and make sure that */srv/http/letsencrypt/* has sufficient permissions.
+| This will roughly look as follows:
+|
+
+* */etc/nginx/domain.conf* & */etc/nginx/cloud.domain.conf*
+
+ .. code:: nginx
+
+ server {
+ listen 80;
+ listen [::]:80;
+ # ...
+ include letsencrypt-challenge.conf;
+ # ...
+ }
+
+|
+
+* */etc/nginx/mail.domain.conf*
+
+ .. code:: nginx
+
+ include geoblock.conf;
+ server {
+ listen 80;
+ listen [::]:80;
+ # ...
+ include letsencrypt-request-check.conf;
+ include letsencrypt-challenge.conf;
+ # ...
+ }
+
+|
+
+certbot staging
++++++++++++++++
+| |website-certbot| has a mode called *staging* that basically gets a *"test certificate"* for you, so you can try if everything is working as expected. Sounds safe? Let's do it (as root or with sudo)!
+
+ .. code:: bash
+
+ certbot certonly \
+ --staging \
+ --agree-tos \
+ --renew-by-default \
+ --email valid@domain.tld \
+ --webroot -w /srv/http/letsencrypt \
+ -d domain.tld \
+ -d www.domain.tld \
+ -d cloud.domain.tld \
+ -d www.cloud.domain.tld \
+ -d mail.domain.tld \
+ -d www.mail.domain.tld
+
+| All domains are defined seprately using the *-d* flag. The above command will give you an error, if something goes wrong and that usually is quite explicit.
+| **Note**: It is very important to test your setup with the staging environment first, because the production environment is rate-limited (and half-baked certs will not do you any good).
+| If everything went right, you will now have an intermediate certificate, that in itself is still useless.
+| Let's go for the real deal then, shall we?
+
+ .. code:: bash
+
+ certbot certonly \
+ --agree-tos \
+ --renew-by-default \
+ --email valid@domain.tld \
+ --webroot -w /srv/http/letsencrypt \
+ -d domain.tld \
+ -d www.domain.tld \
+ -d cloud.domain.tld \
+ -d www.cloud.domain.tld \
+ -d mail.domain.tld \
+ -d www.mail.domain.tld
+
+| This should return a success message, with the note, that your certificate has been saved to */etc/letsencrypt/live/domain.tld/fullchain.pem* and until when that certificate is valid.
+| Congratulations! You just generated a signed certificate, that is valid for the above domains and is recognized by operating systems and browsers!
+|
+
+
+Production
+----------
+| Before we can include the certificate in the |website-nginx| configuration for each domain though, it is time to think about proper |wiki-ssl_tls| settings (|wiki-cipher_suite|, |wiki-ssl_protocols|, |wiki-dh_params|) and security headers (|mozilla-content_security_policy|, |mozilla-cross_origin_resource_sharing|, |mozilla-http_strict_transport_security|, |mozilla-x_content_type_options|, |mozilla-x_frame_options|, |mozilla-x_xss_protection|).
+| Luckily, already a lot of other people have thought about these issues and provided their expertise. Just look at |github-nginx_config|, |blog-ssl_security_on_nginx| or at the |mozilla-ssl_config_generator|.
+|
+
+moar snippets
++++++++++++++
+| To include safe settings for |website-nginx| in all domain configurations, we will create some more snippets and will be happy about this form of reusability!
+|
+
+* */etc/nginx/tls.conf*
+
+ .. code:: nginx
+
+ ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem;
+ ssl_session_cache shared:SSL:50m;
+ ssl_session_timeout 1d;
+ ssl_session_tickets off;
+ ssl_dhparam /etc/nginx/dhparam.pem;
+ ssl_protocols TLSv1.2;
+ ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
+ ssl_prefer_server_ciphers on;
+ ssl_stapling on;
+ ssl_stapling_verify on;
+ ssl_trusted_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem;
+ resolver 8.8.8.8;
+
+| **Note**: I chose a very modern approach towards **ssl_protocols** by enabling only *TLSv1.2* at this point. Depending on your clients, you might want to use *'TLSv1 TLSv1.1 TLSv1.2'* instead.
+| To generate the needed *dhparam.pem* (2048 bits recommended) we can use |website-openssl| as root:
+
+ .. code:: bash
+
+ openssl dhparam -out /etc/nginx/dhparam.pem 2048
+
+* */etc/nginx/security_headers.conf*
+
+ .. code:: nginx
+
+ add_header Content-Security-Policy "default-src 'self'; connect-src 'self'; img-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'";
+ 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";
+
+| A little note on the **Content-Security-Policy** here: Usually one would try to have the targets (**default-src**, **connect-src**, **img-src**, **script-src**, **style-src**) be set to *'self'*. Due to the inline :abbr:`CSS (Cascading Style Sheets)` and Javascript in services such as |website-owncloud|, this is not possible though, so *'unsafe_inline'* and *'unsafe_eval'* have to be added as well.
+| At this point you could of course also choose to create differing *'security_headers'* inclusions for the services you run.
+| Depending on which are running, you will want to monitor your developer console in your browser closely after using this security header. It will tell you, if CFP is blocking some resource (and possibly making it unusable).
+
+domain configurations
++++++++++++++++++++++
+
+| Following are the three different configurations for the services (I won't go into detail about |readthedocs-uwsgi| here, but in a coming article I will).
+
+* */etc/nginx/domain.conf*:
+
+ .. code:: nginx
+
+ # redirect all unencrypted traffic to https
+ server {
+ listen 80 default_server;
+ server_name domain.tld www.domain.tld;
+ return 301 https://domain.tld$request_uri;
+ }
+
+ # redirect all traffic to www. to the plain url
+ server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name www.domain.tld;
+ return 301 https://domain.tld$request_uri;
+ }
+
+ server {
+ listen 443 default_server;
+ listen [::]:443 ssl default_server;
+ server_name domain.tld;
+ include tls.conf;
+ # your pelican blog resides here
+ root /srv/http/websites/domain.tld;
+ # make sure to log
+ access_log /var/log/nginx/access.domain.log;
+ error_log /var/log/nginx/error.domain.log;
+ error_page 403 404 /404/index.html;
+ error_page 500 502 503 504 /50x.html;
+ # include security headers
+ include security_headers.conf;
+ # include the letsencrypt snippet
+ include letsencrypt-challenge.conf;
+
+ location / {
+ index index.html index.htm;
+ try_files $uri $uri/ $uri/index.html;
+ }
+
+ location = /robots.txt {
+ allow all;
+ log_not_found off;
+ access_log off;
+ }
+
+ location = /50x.html {
+ root /usr/share/nginx/html;
+ }
+ }
+
+|
+
+* */etc/nginx/cloud.domain.conf*
+
+ .. code:: nginx
+
+ # redirect all unencrypted traffic to https
+ server {
+ listen 80;
+ listen [::]:80;
+ server_name cloud.domain.tld www.cloud.domain.tld;
+ return 301 https://cloud.domain.tld$request_uri;
+ }
+
+ # redirect www. to the plain domain
+ server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name www.cloud.domain.tld;
+ return 301 https://cloud.domain.tld$request_uri;
+ }
+
+ server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name cloud.domain.tld;
+ include tls.conf;
+ error_page 403 /core/templates/403.php;
+ error_page 404 /core/templates/404.php;
+ # make sure to log
+ access_log /var/log/nginx/access.cloud.domain.log;
+ error_log /var/log/nginx/error.cloud.domain.log;
+ #this is to avoid Request Entity Too Large error
+ client_max_body_size 10G;
+ # include security headers
+ include security_headers.conf;
+ # include the letsencrypt snippet
+ include letsencrypt-challenge.conf;
+
+ location = /robots.txt {
+ allow all;
+ log_not_found off;
+ access_log off;
+ }
+
+ location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README) {
+ deny all;
+ log_not_found off;
+ access_log off;
+ }
+
+ location ~ ^(.+\.php)(.*)$ {
+ include uwsgi_params;
+ uwsgi_modifier1 14;
+ uwsgi_pass unix:/run/uwsgi/owncloud.sock;
+ uwsgi_intercept_errors on;
+ }
+
+ location / {
+ root /usr/share/webapps/owncloud;
+ index index.php;
+ rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
+ rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
+ rewrite ^/.well-known/carddav /remote.php/dav/ redirect;
+ rewrite ^/.well-known/caldav /remote.php/dav/ redirect;
+ rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
+ rewrite ^/caldav(.*)$ /remote.php/dav$1 redirect;
+ rewrite ^/carddav(.*)$ /remote.php/dav$1 redirect;
+ rewrite ^/webdav(.*)$ /remote.php/dav$1 redirect;
+ try_files $uri $uri/ /index.php;
+ }
+
+ location ~ ^/.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
+ expires 30d;
+ access_log off;
+ }
+ }
+
+|
+
+* */etc/nginx/mail.domain.conf*
+
+ .. code:: nginx
+
+ # include the geoblock snippet
+ include geoblock.conf;
+
+ # redirect all unencrypted traffic to https
+ server {
+ listen 80;
+ listen [::]:80;
+ server_name mail.domain.tld www.mail.domain.tld;
+ return 301 https://mail.domain.tld$request_uri;
+ }
+
+ # redirect www. to the plain domain
+ server {
+ listen 443;
+ listen [::]:443 ssl;
+ server_name www.mail.domain.tld;
+ return 301 https://mail.domain.tld$request_uri;
+ }
+ server {
+ listen 443 ssl;
+ listen [::]:443 ssl;
+ server_name mail.domain.tld;
+ include tls.conf;
+ # make sure to log
+ access_log /var/log/nginx/access.mail.domain.log;
+ error_log /var/log/nginx/error.mail.domain.log;
+ root /usr/share/webapps/roundcubemail;
+ #this is to avoid Request Entity Too Large error
+ client_max_body_size 20M;
+ # include security headers
+ include security_headers.conf;
+ # include the request-check snippet
+ include letsencrypt-challenge.conf;
+ # include the letsencrypt snippet
+ include letsencrypt-challenge.conf;
+
+ location / {
+ index index.php;
+ try_files $uri $uri/$args @roundcubemail;
+ }
+
+ location @roundcubemail {
+ include uwsgi_params;
+ uwsgi_modifier1 14;
+ uwsgi_pass unix:/run/uwsgi/roundcubemail.sock;
+ }
+
+ location ~ ^/favicon.ico$ {
+ root /usr/share/webapps/roundcubemail/skins/classic/images;
+ log_not_found off;
+ access_log off;
+ expires max;
+ }
+
+ location = /robots.txt {
+ allow all;
+ log_not_found off;
+ access_log off;
+ expires 30d;
+ }
+
+ # Deny serving some files
+ location ~ ^/(composer\.json-dist|composer\.json|package\.xml|CHANGELOG|INSTALL|LICENSE|README\.md|UPGRADING|bin|config|installer|program\/(include|lib|localization|steps)|SQL|tests)$ {
+ deny all;
+ }
+
+ # Deny serving files beginning with a dot, but allow letsencrypt acme-challenge
+ location ~ /\.(?!well-known/acme-challenge) {
+ deny all;
+ access_log off;
+ log_not_found off;
+ }
+ }
+
+| As you can see here, you have to exclude *.well-known/acme-challenge/* from denying access to all directories beginning with a dot.
+|
+
+Bringing it up
+++++++++++++++
+You should now check your |website-nginx| configuration (as root):
+
+ .. code:: bash
+
+ nginx -t
+
+| This should tell you if something is wrong. Make sure to fix all problems, else |website-nginx| will not come back up after restarting it!
+| If all is well, restart the web server (as root):
+
+ .. code:: bash
+
+ systemctl restart nginx
+
+| Et voila! Your website should now serve over https!
+| You might want to use the |website-mozilla_observatory| now to scan for issues in your setup and to optimize it.
|
+
+Postfix
++++++++
+Your mail server can also use this certificate now (if your |wiki-mx_record| points to one of the domains the certificate was issued for).
+
+* */etc/postfix/main.cf*
+
+ .. code:: ini
+
+ smtpd_tls_cert_file = /etc/letsencrypt/live/domain.tld/fullchain.pem
+ smtpd_tls_key_file = /etc/letsencrypt/live/domain.tld/privkey.pem
+
+Dovecot
++++++++
+The same counts for your :abbr:`IMAP (Internet Message Access Protocol)` server:
+
+* */etc/dovecot/dovecot.conf*
+
+ .. code:: ini
+
+ ssl_cert = </etc/letsencrypt/live/domain.tld/fullchain.pem
+ ssl_key = </etc/letsencrypt/live/domain.tld/privkey.pem
+
+Prosody
++++++++
+| The :abbr:`XMPP (Extensible Messaging and Presence Protocol)`/Jabber server is unfortunately not able to directly access the data in */etc/letsencrypt/live/domain.tld*, because it runs as its own user (*prosody*).
+| You can work around this issue by either changing many permissions, or copy the set of files over to */etc/prosody/certs/* and set these up in your configuration.
+| I recommend the latter, as otherwise you will have to change many file and directory permissions, that are seemingly handled by |website-certbot| and thus lower the overall security of your system.
|
+* */etc/prosody/prosody.cfg.lua*
+
+ .. code:: lua
+
+ ssl = {
+ certificate = "/etc/prosody/certs/fullchain.pem";
+ key = "/etc/prosody/certs/privkey.pem";
+ }
+
+Renewal
+-------
+| During the creation of the certificate you might have already seen, that it is only valid for 90 days. This is ultimately not a bad thing, as now you will have a very easy time renewing it.
+| When using |website-certbot| for the first time to create your real certificate, it automatically saved a configuration file for your domain under */etc/letsencrypt/renewal/domain.tld.conf*.
+| This is a perfect time for testing it (as root):
+
+ .. code:: bash
+
+ certbot renew --dry-run
+
+| Did everything run smoothly? Great! You can now have |website-certbot| renew your certificate, once it is due.
+| |website-eff| recommends running the renewal twice daily for the chance to stay online in case |website-letsencrypt| has to revoce its root certificate for some reason (let us hope that won't happen...).
+| On |website-archlinux| a |website-systemd| service and timer would be the way to do it.
+|
+
+* */etc/systemd/system/certbot.service*
+
+ .. code:: ini
+
+ [Unit]
+ Description=Let's Encrypt renewal
+
+ [Service]
+ Type=oneshot
+ ExecStart=/usr/bin/certbot renew --quiet --agree-tos
+ ExecStartPost=/usr/bin/cp --remove-destination /etc/letsencrypt/live/domain.tld/fullchain.pem /etc/letsencrypt/live/domain.tld/privkey.pem /etc/prosody/certs/
+ ExecStartPost=/usr/bin/chown prosody /etc/prosody/certs/fullchain.pem ; /usr/bin/chown prosody /etc/prosody/certs/privkey.pem ; /usr/bin/chmod u-w,g-r,o-r /etc/prosody/certs/privkey.pem
+ StandardError=syslog
+ NotifyAccess=all
+ KillSignal=SIGQUIT
+ PrivateDevices=yes
+ PrivateTmp=yes
+ ProtectSystem=full
+ ReadWriteDirectories=/etc/letsencrypt /etc/prosody/certs
+ ProtectHome=yes
+ NoNewPrivileges=yes
+
+| **Note**: If not using |website-prosody| it's safe to remove */etc/prosody/certs* from the **ReadWriteDirectories** directive and get rid of the **ExecStartPost** directives all together. They are there for providing |website-prosody| with the certificate in a safe manner.
+|
+
+* */etc/systemd/system/certbot.timer*
+
+ .. code:: ini
+
+ [Unit]
+ Description=Daily renewal of Let's Encrypt's certificates
+
+ [Timer]
+ OnCalendar=daily
+ RandomizedDelaySec=1day
+ Persistent=true
+
+ [Install]
+ WantedBy=timers.target
+
+| The above timer will start the renewal process daily with a random time offset.
+| You can now easily start the service (as root):
+
+ .. code:: bash
+
+ systemctl start certbot
+
+| Enable and start its timer:
+
+ .. code:: bash
+
+ systemctl enable certbot.timer
+ systemctl start certbot.timer
+
+| Enjoy your encrypted services!
+
+
.. |blog-letsencrypt-1_million_certificates| raw:: html
<a href="https://letsencrypt.org/2016/03/08/our-millionth-cert.html" target="_blank">the amount of issued certificates has grown over 1 million in just four months</a>
@@ -168,3 +756,123 @@ _________________
<a href="https://archlinux.org" target="_blank">Arch Linux</a>
+.. |wiki-acme| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Automated_Certificate_Management_Environment" target="_blank">ACME</a>
+
+.. |website-python| raw:: html
+
+ <a href="https://www.python.org/" target="_blank">Python</a>
+
+.. |website-certbot| raw:: html
+
+ <a href="https://certbot.eff.org/" target="_blank">certbot</a>
+
+.. |eff-certbot-nginx-howto| raw:: html
+
+ <a href="https://certbot.eff.org/#arch-nginx" target="_blank">what the EFF has to tell you</a>
+
+.. |wiki-arch-letsencrypt| raw:: html
+
+ <a href="https://wiki.archlinux.org/index.php/Certbot" target="_blank">useful article</a>
+
+.. |website-nginx| raw:: html
+
+ <a href="https://www.nginx.org/" target="_blank">nginx</a>
+
+.. |letsencrypt-howto| raw:: html
+
+ <a name="letsencrypt-howto"></a>
+
+.. |website-roundcube| raw:: html
+
+ <a href="https://roundcube.net/" target="_blank">roundcube</a>
+
+.. |readthedocs-uwsgi| raw:: html
+
+ <a href="https://uwsgi-docs.readthedocs.io/en/latest/" target="_blank">uWSGI</a>
+
+.. |wiki-private_network| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces" target="_blank">private network</a>
+
+.. |website-letsencrypt_acme_clients| raw:: html
+
+ <a href="https://letsencrypt.org/docs/client-options/" target="_blank">another client</a>
+
+.. |wiki-san| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Subject_Alternative_Name" target="_blank">Subject Alternative Name (SAN)</a>
+
+.. |wiki-cipher_suite| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Cipher_suite" target="_blank">cipher suite</a>
+
+.. |wiki-ssl_protocols| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Transport_Layer_Security#History_and_development" target="_blank">protocols</a>
+
+.. |wiki-dh_params| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Diffie-Hellman_key_exchange" target="_blank">Diffie-Hellman key exchange</a>
+
+.. |wiki-ssl_tls| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/Transport_Layer_Security" target="_blank">SSL/TLS</a>
+
+.. |mozilla-content_security_policy| raw:: html
+
+ <a href="https://wiki.mozilla.org/Security/Guidelines/Web_Security#Content_Security_Policy" target="_blank">Content Security Policy (CSP)</a>
+
+.. |mozilla-cross_origin_resource_sharing| raw:: html
+
+ <a href="https://wiki.mozilla.org/Security/Guidelines/Web_Security#Cross-origin_Resource_Sharing" target="_blank">Cross-origin Resources Sharing (CORS)</a>
+
+.. |mozilla-http_strict_transport_security| raw:: html
+
+ <a href="https://wiki.mozilla.org/Security/Guidelines/Web_Security#HTTP_Strict_Transport_Security" target="_blank">HTTP Strict Transport Security (HSTS)</a>
+
+.. |mozilla-x_content_type_options| raw:: html
+
+ <a href="https://wiki.mozilla.org/Security/Guidelines/Web_Security#X-Content-Type-Options" target="_blank">X-Content-Type-Options</a>
+
+.. |mozilla-x_frame_options| raw:: html
+
+ <a href="https://wiki.mozilla.org/Security/Guidelines/Web_Security#X-Frame-Options" target="_blank">X-Frame-Options (XFO)</a>
+
+.. |mozilla-x_xss_protection| raw:: html
+
+ <a href="https://wiki.mozilla.org/Security/Guidelines/Web_Security#X-XSS-Protection" target="_blank">X-XSS-Protection</a>
+
+.. |github-nginx_config| raw:: html
+
+ <a href="https://gist.github.com/plentz/6737338" target="_blank">this</a>
+
+.. |blog-ssl_security_on_nginx| raw:: html
+
+ <a href="https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html" target="_blank">this</a>
+
+.. |mozilla-ssl_config_generator| raw:: html
+
+ <a href="https://mozilla.github.io/server-side-tls/ssl-config-generator/" target="_blank">Mozilla's SSL config generator for web servers</a>
+
+.. |website-owncloud| raw:: html
+
+ <a href="https://owncloud.org" target="_blank">ownCloud</a>
+
+.. |website-mozilla_observatory| raw:: html
+
+ <a href="https://observatory.mozilla.org" target="_blank">Mozilla Observatory</a>
+
+.. |wiki-mx_record| raw:: html
+
+ <a href="https://en.wikipedia.org/wiki/MX_record" target="_blank">MX record</a>
+
+.. |website-systemd| raw:: html
+
+ <a href="https://www.freedesktop.org/wiki/Software/systemd/" target="_blank">systemd</a>
+
+.. |website-prosody| raw:: html
+
+ <a href="https://prosody.im" target="_blank">prosody</a>
+