[Python-Dev] SSL certs

"Martin v. Löwis" martin at v.loewis.de
Thu Sep 13 09:20:16 CEST 2007

> My understanding is that the client tells the server which hostname it
> wants to use; the server should then pass down that information.  That's
> how virtual hosting works in the first place.  The only difference with
> SSL is that the hostname must have a unique IP address, so that when the
> client does a reverse DNS to validate the IP address presented by the SSL
> certificate, it all comes together correctly.

Unfortunately, it does not quite work that way. The client tells the
server what hostname to use only *after* the SSL connection has been
established, and certificates being exchanged (in the Host: header).
So the Host: header cannot be used for selecting what certificate to
present to the client.

*That* is the reason why people typically assume they have to have
different IP addresses for different SSL hosts: certificate selection
must be done based on IP address (which is already known before
the SSL handshaking starts). There is no need for the client to do
a reverse name lookup, and indeed, the client should *not* do a
reverse DNS lookup to check the server's identity. Instead, it should
check the host name it wants to talk to against the certificate.

However, there is an alternative to using multiple IP addresses:
one could also use multiple "subject alternative names", and create
a certificate that lists them all.

> There are, of course, wildcard certs; I don't understand how those work.

The same way: the client does *not* perform a reverse name lookup.
Instead, it just matches the hostname against the name in the
certificate; if the certificate is for *.python.org (say) and the
client wants to talk to pypi.python.org, it matches, and hostname
verification passes. It would also pass if the client wanted to
talk to cheeseshop.python.org, or wiki.python.org (which all have
the same IP address).


More information about the Python-Dev mailing list