If i could setup a DNS server that responds with my server's IP for a certain domain, along with redirecting https and all DNS queries requests to my local https site and my local DNS server respectively, could this result the client browser getting a site certificate over https conatining credentials that match up with what the browser is getting from its DNS queries, thereby avoiding the "certificate untrusted" error?
This is based on the logic that if i only redirected https traffic and left DNS to some external server, the DNS could respond to the client's queries with an IP that doesn't match the one in the certificate thus generating the error due to the mismatch.
If it is not the case that i can do so, how does the browser know to trust the certificate it receives? Does it compare the IP given in the cert with what DNS info it has?