At the moment Triplebit is only using standard nginx for a Mastodon installation, using the default nginx template included with Mastodon. Thankfully, Debian's standard nginx package uses OpenSSL 3.5, so all three standardized ML-KEM hybrid key exchange groups are available without installing alternative packages or compiling anything.
Note
The context behind this change is that we believe 256-bit ECC to be unsafe, more details in our transition announcement. This guide deals with our webservers specifically, but may be a useful reference for your own.
Configuring Nginx
We will edit /etc/nginx/sites-available/mastodon.
To that file, we will add a ssl_conf_command line:
ssl_conf_command Groups SecP384r1MLKEM1024:X25519MLKEM768:SecP256r1MLKEM768/P-384;
Important
The
/separator in thessl_conf_commandline is important here. OpenSSL supports separating groups into priority tiers, so this configuration prioritizes hybrid PQC over classical key exchange even if doing so requires an additional handshake round trip.
We will also replace the ssl_ciphers line with this line to remove the finite-field DHE suites:
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
Combined with the current default configuration options, these changes mean that our entire SSL configuration section (every line starting with ssh_) should look like this, and there should be no other SSL lines:
ssl_protocols TLSv1.2 TLSv1.3;
ssl_conf_command Groups SecP384r1MLKEM1024:X25519MLKEM768:SecP256r1MLKEM768/P-384;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
Tip
This is generally applicable to most nginx configs.
We use a separate subdomain and nginx configuration file for our media storage, so we will make similar changes in that file as well. If you have multiple sites in nginx, just make sure you are checking every site you have enabled.
Replacing our Let's Encrypt certificates
We now need to change our Let's Encrypt certificate to use a P-384 key. We can see our current certificates with the sudo certbot certificates. Again in this case, the server we are operating on has two certificates (one for Mastodon, and one for the media backend), so we will renew both with a stronger key:
sudo certbot renew \
--cert-name example.com \
--key-type ecdsa \
--elliptic-curve secp384r1 \
--new-key \
--force-renewal
sudo certbot renew \
--cert-name files.example.com \
--key-type ecdsa \
--elliptic-curve secp384r1 \
--new-key \
--force-renewal
Then check your configuration: nginx -t, and restart nginx: systemctl restart nginx.
Testing Our Configuration
We can test our configurations with the following webserver-test.sh script:
#!/bin/bash
for group in X25519MLKEM768 SecP384r1MLKEM1024 P-384 X25519 P-256; do
echo "Testing $group"
openssl s_client \
-connect "$domain:443" \
-servername "$domain" \
-tls1_3 \
-groups "$group" \
-brief </dev/null
done
When running domain=example.com bash webserver-test.sh (for example) in a terminal, before our changes were applied we would generally see "CONNECTION ESTABLISHED" under four of the five keys, with SecP384r1MLKEM1024 failing to connect.
After the change is applied we will see the connection now establishes with SecP384r1MLKEM1024, and we will no longer see "CONNECTION ESTABLISHED" underneath X25519 and P-256.
To my knowledge, there are no browsers which support X25519 but do not support P-384, so this change should not introduce compatibility issues. For performance reasons, browsers will typically prefer X25519 to P-384 when both are offered, so disabling X25519 explicitly will therefore improve security.