On my VPS server with cPanel/WHM, I have 2 accounts: domain1 and domain2.
Each of these domains are the main domains for their accounts. Meaning that domain1 has other alias domains as well, and domain2 has also some additional alias domains. The ip of these accounts is different. Meaning that domain1 has one ip and domain2 has it's own ip.
For domain1, I've added a DNS A record that points to domain2's ip. Now, when accessing domain1, the website from domain2 is served as expected because of this "redirection", which is what I want.
Both of these domains, have also SSL valid certificates for their own domains and alias domains.
The problem is that when I access domain1 and the website from domain2 is returned, the SSL certificate from domain2 is also returned, which of course does not cover the domain1, meaning that the connection is marked as unsecure.
I've checked with 'whynopadlock.com' and the result was the expected one: the SSL certificate is valid indeed, but since it belongs from domain1, it does not provide coverage for domain2 as well.
Therefore, how can I fix this SSL issue?
Please note that this behavior was successfully working on my previous server, but I had to migrate it to a new server where it doesn't work anynore and I don't know how it did worked on the previous server. One thing for sure is that there was no multi domain SSL certificate, but everything worked by default using AutoSSL and SSL certificates provided by Let's Encrypt for free.
cPanel/WHM doesn't let me to add domain1 to the domain2's account, because it's already in use.
I don't want to move domain1 to domain2's account for other reasons. I want to keep them separate as they are, but just to fix this SSL error.