docker-mailserver: [BUG] Let's encrypt certificate renew not recognised. mailserver uses old one and not updated one.
Miscellaneous first checks
- I checked that all ports are open and not blocked by my ISP / hosting provider.
- I know that SSL errors are likely the result of a wrong setup on the user side and not caused by DMS itself. I’m confident my setup is correct.
Affected Component(s)
mailserver does not use renewed let’s encrypt certificate
What happened and when does this occur?
I'm using traefik v2 to get and renew certificates. The traefik json which holds the certificates has been mounted as volume into the mailserver docker container. When the certificate gets renewed by traefik (~4 weeks before expiry), the mailserver does not recognise this certificate and keeps using the old one.
I checked certificate with https://www.checktls.com/TestReceiver and it still shows the old one. Opening the Website that uses the same hostname and certificate, it shows the renewed one.
When I do a restart of the docker container, the new certificate is recognized and from there on used.
What did you expect to happen?
docker mailserver should recognise the updated / renewed certificate (by traefik2) without restarting the container.
How do we replicate the issue?
1. Setup traefik2, nginx webserver and docker mailserver as described in the docu
2. wait until let's encrypt certificate get's renewed by traefik2
3. check that mailserver does not pick renewed certificate
...
DMS version
v10.1.2
How much RAM is available to DMS explicitly?
more than 4GB
How many CPU cores are available?
less than 4 Cores
Is DMS running in a virtualized environment?
… a virtual private server (VPS) (with virtual CPU cores)
What operating system is DMS running on?
Linux
What instruction set architecture is DMS running on?
x86_64 / AMD64
I/O - Persistent memory
docker volume mount ext4
What container orchestration tool are you using?
Docker Compose
Docker version
No response
Docker Compose version
docker-compose version 1.28.5
The output of uname -a
Linux 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64 GNU/Linux
Important environment variables
Mount point within my docker-compose file:
- /data/acme/:/etc/letsencrypt/
I tried
- /data/acme/acme.json:/etc/letsencrypt/acme.json:ro
last time but same result.
Relevant log output
No response
Other relevant information
No response
What level of experience do you have with Docker and mail servers?
Trust me, I’m a (computer) engineer! [expert]
Code of conduct
- I have read this project’s Code of Conduct and I agree
- I have read the README and the documentation and I searched the issue tracker but could not find a solution
Improvements to this form?
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 43 (27 by maintainers)
I updated to 10.3.0. Next auto-renew is around 4th of December. Therefore perfect timing from your end to release this! 😃
Will give you an update afterwards.
Renewal was successful! 😃 No manual restar required this time. Thanks a lot!!
I copied the files from mail to mail.somedomain.com and restarted postfix/dovecot via
supervisorctl restart dovecot / postfix
. The renewed certificate is in use now:@zaphoodb how did it go? Renewal went smoothly this time? 😃
I’m very familiar with docker and running traefik as a reverse proxy (and using it to get letsencrypt certificates). I am using docker-mailserver since beginning of this year. So far everything worked. But I newer saw that docker-mailserver was picking up the changes to the acme.json (made by traefik) automatically. Only on a restart or re-create of the docker container, the updated certificate was used. Therefore I think it’s an option that this never worked as designed.
docker-mailserver docu about traefik:
The file is also monitored for changes and will trigger a reload of the mail services (Postfix and Dovecot).
This is newer saw happening.Yep,we don’t control HOSTNAME, it’s a docker thing. We override it in the scripts though. Sorry for brevity; traveling
How? We set it by whatever the returned value for a match in
/etc/hosts
is currently:https://github.com/docker-mailserver/docker-mailserver/blob/34ba3c2a5b0f709a1680a779fda3da338535a063/target/scripts/helper-functions.sh#L302
So I’m not sure how
$HOSTNAME
would bemail
when creating a folder with that value unless something was wrong in/etc/hosts
config.If there is no other lines with
mail
I’m not sure what is going on there 🤔Maybe I misunderstood how
$HOSTNAME
has becomemail
and @NorseGaud is correct, but I’m not sure where that mishap occurs.Ah…
$HOSTNAME
is only altered in the scripts scope, soecho $HOSTNAME
in the container would be misleading (since this value is output byhostname
default command that matches/proc/sys/kernel/hostname
which was set for the container).I double checked and in my
docker-compose.yml
I have set following:Output of
docker exec mailserver bash -c 'cat /etc/hosts'
:I do not use any loadbalancer (e.g. traefik) in front of the mailserver container. Therefore docker creates an own network just for this container:
Executing this
docker exec mailserver bash -c 'openssl x509 -noout -text -in /etc/letsencrypt/live/"${HOSTNAME}"/fullchain.pem
raises an error now:Can't open /etc/letsencrypt/live/mail/fullchain.pem for reading, No such file or directory
. That’s because I updated the docker container accidentially. This removed themail
folder which the update certificates process created (and did not overwritemail.somedomain.com
) instead. But foldermail.somedomain.com
exists and the correct certificate is used from there.That’s expected. The variable becomes whatever you set in the docker config’s ‘hostname’