Forum archive
LetsEncrypt for Postfix Email Relay Configuration
In the past I have deployed TKLX servers using a manually obtained SSL certificate which I then upload and embed in the appropriate configuration files (apache, webmin, stunnel, postfix).
I deployed my first LetsEncrypt server (version 15) and it works fine for the apache server out of the box but I didn't get around to converting my postfix server from direct to relay until now...and I realise I don't know how to go about ensuring the renewed LetsEncrypt cert automatically gets applied into my postfix server configuration for relayed email.
Can you clarify which TKLX appliance features from the following list currently get configured / reconfigured on a LetsEncrypt connection / renewal?
1) Apache
2) Webmin
3) Stunnel
4) Postfix
Thanks in advance. Much appreciated :-)
NOTE: Could you answer from V15.x as well as V16.x if they are different.
TBH, I haven't played with Let's Encrypt certs with Postfix but I can't see why they wouldn't work?!
The Confconsole Let's Encrypt integration (for both v15.x & v16.x) updates and regenerates the certs/key that you can find here:
The cert.pem & cert.key files are used for Apache, Nginx, Lighty and/or Tomcat (i.e. all primary servers running on ports 80 & 443); as well as Stunnel (Webshell and Webmin). The crt file is not used anywhere in particular AFAIK, but I'm actually not sure.
v16.x introduced the ability to easily regenerate the DH parameters file (/etc/ssl/private/dhparams.pem) too. We've always been generating it on firstboot, but it defaults to an ok, but relatively low (1024) bitrate to make firstboot quicker. Regenerating with a higher bitrate is recommended (2048 is recommended) and will likely increase score on testers such as SSL Labs. You can do that via Confconsole >> Advanced >> System Settings >> Regenerate dhparams. Or via commandline like this:
The data from the DH parameters file (/etc/ssl/private/dhparams.pem) is also included in the cert.pem (as is the data from the cert.key as well). We do it like that so that a single set up "just works" across multiple different webservers that all seem to do things a little differently (some use separate individual files, others use a consolidated file; those that expect separate files ignore irrelevant data).
It appears that Postfix doesn't use "perfect forward secrecy" (what the DH params are used for) by default. So it's security could be improved by configuring that, although I've not played with it at all, so I'm not sure how that would go. FWIW you'll find a good starting point relevant to the v16.x compatible config via the Mozilla SSL Configuration Generator (the URL should have the right versions of Postfix and OpenSSL).
The cert/key that Postfix uses by default are /etc/ssl/certs/ssl-cert-snakeoil.pem & /etc/ssl/private/ssl-cert-snakeoil.key (set in /etc/postfix/main.cf and regenerated on firstboot). I had a quick peek at the defaults and on face value, it appears that just reconfiguring Postfix to use the cert.pem & cert.key in /etc/ssl/private would probably "just work"?!
I did try doing that (just our self signed cert; not a "proper" Let's Encrypt one) on a v16.0 server I happen to be working on ATM (but no other tweaks as suggested above) and restarted Postfix and it didn't cause any issues on face value. However, I have not properly tested it actually sending mail so can't comment at all on how effective it might be in reality! Having said that, I don't see any reason why it wouldn't work?!
Even if it's doesn't for some reason, I would imagine that creating/writing a postfix compatible cert via the dehydrated hook script should be fairly straight forward. FWIW the env vars used there are set within the Dehydarated wrapper.
In fact, if you can confirm that it works (improved Postfix config and/or certificate generation), then I think that we should look to add that into the Postfix setup and/or Let's Encrypt integration by default!
So let me know how you go and I'm more than happy to help out if you hit any issues. I certainly don't consider myself expert on Postfix (or certs or SSL even for that matter) but I have some basic knowledge and intimately know TurnKey ;)