I have an apache server configured as a virtual host (name-based), suppose that the ip is 186.54.251.57, if I enter that ip address the apache home page will be displayed...
if I enter example1.com with either http or https it works fine as it has an R3 certificate (letsencrypt)
example2.com also works fine and so on (as long as the domains are set to apache2)
The problem is when I add a domain to my DNS servers, then the A record points to the address 186.54.251.57 but the domain example3.com is not yet configured in apache, if I enter the browser and type http://example3. com will take me to the apache home page, but the problem comes when I enter through https://example3.com, as the domain does not yet have an ssl certificate because it is not configured in apache, so it loads the content of example2.com because it associates the ssl certificate of the other page and consequently shows its content...
How can I prevent that? What if you have A record in the dns that points to the ip address of the apache server but if you don't have an ssl certificate then don't load another foreign page?