6.7 KiB
Provisioning TLS certificates
As explained in the deployment considerations, federation requires the use of TLS as most instances refuse to federate over unencrypted transports.
GoToSocial comes with built-in support for provisioning and renewing its own TLS certificates through Lets Encrypt. This guide looks at how you can provision your own certificates independently from GoToSocial. This can be useful if you want full control over how the certificates are provisioned, or because you're using a reverse proxy which is doing TLS termination.
There are a few different ways you can get TLS certificates:
- Buy them from a vendor, typically valid for 2 years
- Get them from your cloud provider, validity depends on their product constraints
- Get them from an ACME-compatible provider like Lets Encrypt, typically valid for 3 months at a time
In this guide we'll only look at option 3, an ACME-compatible vendor.
General approach
The way you'll provision certificates through Lets Encrypt is:
- Install an ACME client on your server
- Configure the ACME client to provision your certificates
- Configure a piece of software to use those certificates
- Enable a timer/cron to regularly renew the certificates
- Signal to the necessary applications they need to reload or restart to pick up the new certificates
Certificates are provisioned using a challenge, a way to verify that you're requesting a certificate for a domain you control. You'll typically use one of:
- HTTP challenge
- DNS challenge
The HTTP challenge requires serving certain files on port 80 on the domains you're requesting a certificate for under the /.well-known/acme/
path. This is the default challenge type.
The DNS challenge happens entirely out of band but requires you to update a DNS TXT record. This approach is only feasible if your DNS registrar provides an API through which you can modify DNS records so that your ACME client can complete this challenge.
Clients
The official Lets Encrypt client is certbot and it's usually packaged in your (Linux) distribution of choice. Certain reverse proxies like Caddy and Traefik have built-in support for provisioning certificates using the ACME protocol.
A couple of other clients of note that you can consider using:
- acme-client for OpenBSD using the privilege separation features of the platform
- lacme, which is built with process isolation and minimal privileges in mind in the same vein as acme-client but for Linux
- Lego, an ACME client and library written in Go
- mod_md, when using Apache 2.4.30+
DNS challenge
For the DNS challenge, the API of your registrar needs to be supported by your ACME client. Though certbot has a few plugins for popular providers, you probably want to look at the dns-multi plugin instead. It leverages Lego under the hood which supports a much wider array of providers.
Configuration
There are 3 configuration options that are important:
letsencrypt-enabled
controls if GoToSocial will try to provision its own certificatestls-certificate-chain
filesystem path where GoToSocial can find the TLS certificate chain + the public keytls-certificate-key
filesystem path where GoToSocial can find the associated TLS private key
Without reverse proxy
When running GoToSocial directly exposed to the internet, but you still want to use your own certificates you can set the following options:
letsencrypt-enabled: false
tls-certificate-chain: "/path/to/combined-certificate-chain-public.key"
tls-certificate-key: "/path/to/private.key"
This disables the built-in provisioning of certificates through Lets Encrypt and tells GoToSocial where to find the certificates on disk.
!!! tip Restart GoToSocial after renewing your certificates. It won't pick up on certificate rotation by itself when they are provided like this.
With reverse proxy
When running GoToSocial behind a reverse proxy which you also use for TLS termination, you'll need the following instead:
letsencrypt-enabled: false
tls-certificate-chain: ""
tls-certificate-key: ""
It's important to ensure the tls-certificate-*
options are unset or set to the empty string. Otherwise GoToSocial will attempt to handle TLS itself.
!!! danger "Protocol configuration option"
Do not change the protocol
configuration option to http
. This should only ever by set to http
for development purposes. It needs to be set to https
even when running behind a TLS-terminating reverse proxy.
You'll also want to change the port
GoToSocial binds on, so it no longer tries to use port 443.
To configure TLS in your reverse proxy, please refer to their documentation:
!!! tip When configuring TLS in your reverse proxy, ensure you configure a reasonably modern set of compatible versions and ciphers. You can use the "Intermediate" configuration from the Mozilla SSL Configuration Generator.
Check the documentation of your reverse proxy on whether you have to reload or restart it after certificates have changed. Not all reverse proxies detect this.
Guides
There are a number of good resources on the internet explaining how to set all of this up.
- ArchWiki entry on certbot
- Gentoo wiki entry on Lets Encrypt
- Linode guide on certbot for Fedora, RHEL/CentOS, Debian and Ubuntu
- Digital Ocean guides on Lets Encrypt on Ubuntu 22.04 with nginx or apache