OpenLiteSpeed: mail.<domain>:443 serves the server hostname certificate, Thunderbird shows a security exception during calendar/address book discovery

toktokcity

Verified User
Joined
Apr 29, 2016
Messages
122
Location
The Netherlands
Hi all,

We run DirectAdmin with OpenLiteSpeed (CustomBuild) on several servers and see the same thing with every domain. I would like to know if this is expected, or if there is a supported setting for it.

What happens
When a new account is added in Thunderbird (auto configuration), the account is created fine, mail settings are detected correctly. Then, in the step "Discovering address books and calendars…", Thunderbird shows "Add Security Exception" for mail.example.com with "Wrong site: the certificate belongs to a different site". Cancelling or skipping works, and mail keeps working, but customers find the warning alarming.

What I measured
- mail.example.com resolves to the server (A and AAAA).
- Mail ports are fine. On 993, 995, 465, 587 and 25 the certificate is the Let's Encrypt certificate of example.com, with mail.example.com in the SAN list.
- Port 443 on mail.example.com returns the server hostname certificate (CN=<server hostname>), the same for every connection, so it is not intermittent. https://mail.example.com/.well-known/autoconfig/mail/config-v1.1.xml returns 404.
- The reason seems to be that mail.example.com is not a web host on the server: the OpenLiteSpeed vhost for the domain has vhDomain example.com and vhAliases www.example.com only (generated from openlitespeed_vhost.conf), so the request falls through to the default vhost and its certificate.

Questions
1. Is this the expected behaviour on OpenLiteSpeed? The docs say autodiscover is configured automatically on current licenses and that Thunderbird should work without customisation. Is anything different for OpenLiteSpeed than for Apache, where I see mention of a ProxyPassMatch for the mail/autoconfig path?
2. Is there a supported setting (directadmin.conf or CustomBuild option) that makes mail.<domain> answer on 443 with the domain's own certificate?
3. If not, would the recommended way be a custom copy of openlitespeed_vhost.conf where mail.|SDOMAIN| is added to vhAliases? I would rather not maintain a custom template if there is an official way.

Versions: DirectAdmin 1.714, CustomBuild 2, OpenLiteSpeed 1.9.4, Thunderbird 160.

Thanks!
 
Is the hostname really mail.domain.com? Because that is not really a wise decision to use mail als the servers hostname. In the past that caused some odd behaviour of some things. Amongst which the fact that normally mail.domain.com is used for mail addresses (incoming/outgoing mail) for domains, which is also the reason one can not visit mail.domain.com via https ofcourse.
 
Is the hostname really mail.domain.com? Because that is not really a wise decision to use mail als the servers hostname. In the past that caused some odd behaviour of some things. Amongst which the fact that normally mail.domain.com is used for mail addresses (incoming/outgoing mail) for domains, which is also the reason one can not visit mail.domain.com via https ofcourse.
mail.*customer*.com, it works fine for imap and SMTP etc. with SSL. But in the final step in Thunderbird they try to find :443 certificate for calendar purposes.
 
mail.*customer*.com, it works fine for imap and SMTP etc.
Yes so mail.somedomain.com it's just an example. But as long as you use mail.xxx.xxx as hostname, you have a risk encountering odd issues either now or in the future (or both).
That should not happen but we've seen that a lot in the past.

they try to find :443
Which most likely is also cause of that because the hostname is normally web based, not mail based. So web based ssl port is wrongly used.
I would strongly advise to change the hostname. Then check or re-issue certificates again and I'm almost sure your issues will be gone.
 
Sorry, the server is running a different name. s*.domain.com. When installing an account, customers use mail.*. But because that's only 993 and 465 etc, the calendar check can't find 443 certificate and reads the certificate of s*.domain.com which is not a match and gives an error.
 
I think using the host name will fix the issue, but this is frustrating when an account is replaced to a different server. Than I need to ask the customer to make some changes in local installations, which is not an issue when mail.* is used.
 
Than I need to ask the customer to make some changes in local installations, which is not an issue when mail.* is used.
Incorrect. Because it does not need to be the same. By default it works correctly alrealdy.
We have the hostname set for example to serverxx.example.com (just an example) and all clients and customers can use mail.customerdomain.com to send and receive mail, that is the Directadmin default.

So when an account is placed to another server, even if the hostname would be tralala.whatever.com the customer does not need to change 1 single thing because they can still keep using mail.customerdomain.com for their email.

I don't know where you get the idea that a hostname should match a customers mail account. Those are 2 different things.
You can also send me a pm in Dutch (Nederlands) if you want, then we can talk in Dutch and maybe the explanation is a bit easier.
 
The prompt doesn't come from mail autoconfig, it comes from the step after the account is created. Current Thunderbird (the Account Hub code in mail/components/accountcreation/views/email.mjs) looks for CardDAV and CalDAV at https://<domain of the address>, and then, if the incoming server's hostname is on the same site (same registrable domain) as the address, also at https://<incoming hostname>. With mail.example.com as the IMAP server, that second probe goes to https://mail.example.com/. OpenLiteSpeed has no vhost for that name, so the listener answers with its default certificate (the hostname one), and Thunderbird shows the exception dialog.

That's also why the server hostname makes it go away: s*.yourhostingdomain is a different site from the customer's address, so Thunderbird never probes it on 443.

The 404 on mail.example.com/.well-known/autoconfig/... is unrelated. Thunderbird fetches the config from https://autoconfig.example.com/mail/config-v1.1.xml and https://example.com/.well-known/autoconfig/mail/config-v1.1.xml, which is why the mail settings were detected correctly.

To your questions:

  1. With vhDomain example.com and vhAliases www.example.com only, yes, this is what you'd expect. Any client that opens https://mail.example.com gets the same certificate. I haven't compared it with the Apache templates, so I can't say whether Apache behaves differently.
  2. I couldn't find a directadmin.conf or CustomBuild option for it in the docs.
  3. You don't need to fork openlitespeed_vhost.conf. DirectAdmin's "Customizing OpenLiteSpeed" page has a recipe for webmail.example.com that adds a second vhost through /usr/local/directadmin/data/templates/custom/cust_openlitespeed.CUSTOM.8.pre. The same recipe works for mail.:

  • Copy the vhost block from that guide into cust_openlitespeed.CUSTOM.8.pre and change the three webmail lines:
    Code:
    virtualHost mail.|SDOMAIN|-|VH_PORT| {
    ...
     vhDomain                  mail.|SDOMAIN|
     vhAliases                 mail.|SDOMAIN|
  • Keep the |*if SSL_TEMPLATE="1"| … vhssl { keyFile |KEY| certFile |CERT| … } part as it is. That is the domain's own certificate, and you've already seen that it has mail.example.com in its SAN (mail is in the default letsencrypt_list). So no DNS or certificate change is needed, and the vhost points at the same certificate file as the main one, so renewals cover it too.
  • docRoot: the guide uses /var/www/html/roundcube. If you keep it, https://mail.example.com opens webmail, which customers may like. Any directory works for the Thunderbird case.
  • The same page has a variant that adds the vhost only for main domains (not subdomains or domain pointers), using |*if SUB| and |*if HOST_POINTER|, if you want that.
  • Then run da build rewrite_confs.

To check:
Code:
openssl s_client -connect mail.example.com:443 -servername mail.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -ext subjectAltName
It should show the domain's certificate. Thunderbird then gets a valid TLS connection there, finds no CardDAV/CalDAV (unless you run a DAV server), and moves on without the prompt.

(Disclosure: I build ZoneBI, which checks from the outside the certificates a domain serves on HTTPS and on its MX and IMAP servers, along with DNS and SPF/DKIM/DMARC. If you add mail.example.com as its own entry, it flags a certificate on 443 that doesn't match the name. The free plan covers 3 domains: https://zonebi.com/en/?src=directadmin-forum-en-01 )
 
Back
Top