Your question
Stalwart serves the wrong TLS certificate and fails to renew an expired certificate
Environment
- Stalwart version:
0.16.26 - Installation: native Linux installation, running as a systemd service (not Docker)
- Configuration backend: RocksDB
- ACME provider: Let’s Encrypt
- ACME certificate and DNS management: enabled
All domain names, IP addresses, and certificate identifiers in this report have been anonymized.
Problem
Stalwart was serving the wrong TLS certificate for mail.example.com, even when the client explicitly sent mail.example.com as the TLS SNI hostname.
The server presented a Let’s Encrypt certificate with:
- Subject / CN:
example.com - SAN:
DNS:example.com
This certificate does not include mail.example.com.
The same incorrect certificate was served on SMTP ports 25 (STARTTLS), 465 (implicit TLS), and 587 (STARTTLS).
Certificates stored in Stalwart
The certificate list in the Stalwart UI contained two certificates:
- A certificate for
example.com, valid until2026-12-13. - A multi-SAN certificate covering:
autoconfig.example.comautodiscover.example.commail.example.commta-sts.example.comua-auto-config.example.com
The second certificate expired on 2026-10-14.
ACME configuration
The domain example.com was configured to use ACME TLS certificate management with Let’s Encrypt and automatic DNS management.
The Additional Hostnames field contained only example.com. The configuration had worked for approximately three months before the multi-SAN certificate expired.
When I tried to trigger certificate renewal through the admin interface, I received the following message:
Certificate for domain mail.example.com is still valid; renewal is not due until 2026-11-13T09:21:57Z
However, the multi-SAN certificate covering mail.example.com had already expired on 2026-10-14.
There were also multiple failed ACME renewal and DNS management tasks.
Reproduction
Connect to the server while explicitly specifying mail.example.com as SNI:
openssl s_client \
-connect mail.example.com:25 \
-starttls smtp \
-servername mail.example.com
The server returned the certificate for example.com, which did not contain the requested hostname.
The same result occurred on ports 465 and 587.
DNS A resolution for mail.example.com returned <server-ip>. No AAAA record was configured.
Workaround
I tried several approaches through the admin interface to renew the certificate and configure the correct certificate, but they did not resolve the issue.
The issue was eventually resolved by manually creating an ACME renewal task through the Stalwart CLI:
stalwart-cli create task/AcmeRenewal \
--url https://mail.example.com \
--user '<admin-user>' \
--password '<admin-password>' \
-k \
--field domainId=b
After creating this task, Stalwart began serving the correct TLS certificates for all required domains and subdomains. The mail service was working correctly again.
No other changes were required to achieve this result.
Expected behavior
Stalwart should automatically renew ACME-managed certificates when necessary and select the appropriate certificate for each hostname based on the client’s SNI.
If renewal cannot proceed, the system should provide a clear explanation of why it was not attempted, especially when the certificate has already expired.
Questions
- Why did the admin interface report that renewal was not due until
2026-11-13when the multi-SAN certificate had already expired on2026-10-14? - Why did Stalwart serve the certificate for
example.comwhen the client explicitly sentmail.example.comas SNI, despite a certificate coveringmail.example.combeing present in its certificate database? - Why did manually creating an
AcmeRenewaltask resolve the issue for all required domains and subdomains when the normal renewal workflow did not? - Is this expected behavior, a configuration issue, or a bug in ACME renewal scheduling or TLS certificate selection in Stalwart
0.16.26? - Should an administrator ever need to create ACME renewal tasks manually, or should Stalwart handle renewal and certificate selection automatically?
- Is there any configuration change recommended to prevent this issue from recurring?
I would appreciate guidance on the underlying cause and the recommended permanent solution. Since this is a production mail server, I would prefer not to rely on manually creating renewal tasks every time certificates expire.