I can generate a self signed certificate for any Common Name, such as www.google.com. If I have a server at example.com and serve up a certificate with the common name www.google.com and the user accepts it. Would that allow me to MITM a connection to www.google.com with that certificate without them having to accept it again?

If not, what prevents that from working? Does the browser keep a table of certificate fingerprints to the domain which it came from?

I tested this myself and it didn't work, but I'm looking for further validation since it's possible my testing was flawed.

1 Answer 1


If the user adds an explicit connection for a certificate while visiting a site this exception is only added for the combination of this specific target site and this specific certificate. In your specific example it means that the certificate will be accepted only for example.com but not for www.google.com since this exception is only added for the target example.com. It does not matter that the certificate contains a subject alternative name for www.google.com too.

As far as I remember the behavior was actually different long ago where the exception was added for a certificate independent of the site. It was fixed to defend against exactly the scenario you've outlined.

  • This is consistent with my testing, and makes sense for it to be enforced in this way.
    – Hem
    Apr 27, 2018 at 6:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .