Mail Server Certificate for mail.domain.tld is not created, otherwise I wouldn't be writing here.
@Gjimi,
That is no surprise.
The creation of the LE certificate for the
mail server will cause issues due to the existence of the mail.domain.tld
subdomain on your server.
The creation of the LE certificate for the mail.domain.tld
subdomain can and often will cause issues for the creation of the LE certificate for the
mail server and, as a result, often leave the mail server associated with the mail.domain.tld
subdomain exposed (read: it is not associated with a LE certificate).
At this moment, you have a LE certificate for the
hosting part of the mail.domain.tld
subdomain.
In addition, you can expect issues to arise from the fact that you created an Apache alias (on port 443) for the mail.domain.tld
subdomain.
You expect that the Apache alias will be sufficient to assign LE certificates to a
mail server, but it is not - it is only an Apache alias for a (hosting) subdomain that has a name exactly identical to the name mail.domain.tld that is reserved by default for the mail server.
Stated differently, the Apache alias will sooner or later interfere with the proper functioning of and certification of the mail server.
In short, if you simply revert to domain.tld (as opposed to the currently used mail.domain.tld), then you would not have to write here.
The domain.tld approach would simply create LE certificates for the domain that can also be used for the associated mail server.
Stated differently, if you would not have deviated from default setup, you would not have written here with this particular set of questions.
I can only recommend to do a test with a testdomain.tld - create a domain in Plesk, assign a LE certificate to the domain and the mail server.
If that works, then it is obviously clear that your current setup is flawed.
I can highly recommend to
not apply workarounds, since workarounds are not solutions.
Workarounds are merely combatting symptoms of issues that can and should be resolved.
As a final remark, it is normally the case that thread starters are providing all information required to do a proper analysis.
In your case, there is much more to be provided, such as logs and - more importantly - the actual DNS settings.
Not only the original LE error notification indicates a minor issue with DNS, but also the Apache alias workaround indicates minor DNS issues.
In essence, using LE with external DNS providers simply requires that you should have
1 - a DNS A (or AAAA) record for domain.tld
2 - a DNS A (or AAAA) record for *.domain.tld - otherwise, the Apache alias would not work
3 - a DNS A (or AAAA) record for mail.domain.tld - explicit DNS that can be replaced with the record from point 2
4 - a MX record with the value mail.domain.tld
5 - a TXT record for the subdomain _acme-challenge.domain.tld with the value (key) provided by LE during certificate setup
and if you
a) do not have the _acme-challenge.domain.tld TXT record,
and/or
b) a setup in Plesk that "hints" or "instructs" to have a look at another than the aforementioned TXT record,
then LE certification processes will fail miserably.
Please note that it does not make a difference whether or not you are using external DNS or Plesk based DNS - the concept is the same.
Stated differently, by creating the Apache alias and corresponding DNS settings, you are "instructing" LE to have a look at domain.tld (
not mail.domain.tld) and certify domain.tld (
not mail.domain.tld).
As a workaround, this will work, since the certificate for domain.tld
will be assigned to the mail.domain.tld
subdomain and
can be assigned to a mail server associated on the domain.tld
domain.
The reason why this workaround will work is the simple fact that the mail.domain.tld
subdomain has the exact identical name that would otherwise be used by default for the
mail server, being the name mail.domain.tld.
Nevertheless, even when the mail.domain.tld
subdomain is absent, Plesk
can and will assign the LE certificate for domain.tld to the
mail server of domain.tld that has the name mail.domain.tld.
In essence, the Apache alias is an "instruction" to overrule another instruction that makes LE fail.
Stated differently, before the Apache alias, the Plesk setup and/or the DNS setup was not proper.
It can be that DNS is not setup properly.
It can also be the case that you have setup mail.domain.tld
as a subdomain - one should use a
domain setup with the name mail.domain.tld.
As a final remark, I use / have used / test / have tested the setup with both domain.tld and mail.domain.tld for many years now.
I can safely conclude that everything will work like a charm,
unless your Plesk or DNS setup was not proper,
before applying the Apache alias workaround.
As a result, I would not recommend your workaround at all .......... due to the simple fact that the root cause of the problem is not solved.
Kind regards.....