A subdomain uses the certificate of another domain

Hello everybody. I use Virtualmin/webmin on a debian 10.
I have 2 websites on the server (each with a subdomain), and each using its specific certificate created with certbot to have a single wildcard certificate.
The problem is: the certificate sended for the subdomain of domain 1 is the good one, but the one sended for the subdomain of domain 2 is the certificate of domain1! Why ?
The consequence is that the certificate is not for the good domain and antivirus or browsers block the connection.

The whole story is:
I created 2 virtualhosts for 2 websites but it’s the same webapp (one for dev, one for prod).
The webapp uses a subdomain for a back-office but I didin’t want to create all the stuff for complete new virtualhost like Virtualmin does.
The webapp has the simple structure:
/home/domain/www accessible via Internet for all
/home/domain/sub accessible via Internet for back-office
/home/domain/src containing all the scripts for www and sub.
So I just created virtualhosts through Webmin “Apache server” page, for the subdomains.
I created wildcard certificates using certbot/let’s encrypt with DNS method.
Everything works as expected but this bad certificate. The apache confs declare the good certificates for www and sub for each webapp.
If someone can help me with that !

To resolve the issue, I had to create a sub-server for each sub-domain. This created Apache conf for the VIrtualhost, like when I created them directly from Apache server Webmin page. I then replaced the content of these files with the previous content and it works!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.