Issue #5639: Add a *server_hostname* argument to SSLContext.wrap_socket

in order to support the TLS SNI extension.  `HTTPSConnection` and
`urlopen()` also use this argument, so that HTTPS virtual hosts are now
supported.
This commit is contained in:
Antoine Pitrou 2010-10-22 18:19:07 +00:00
parent 4ebfdf01bb
commit d532321f7b
9 changed files with 137 additions and 14 deletions

View file

@ -1081,7 +1081,9 @@ else:
self.sock = sock
self._tunnel()
self.sock = self._context.wrap_socket(sock)
server_hostname = self.host if ssl.HAS_SNI else None
self.sock = self._context.wrap_socket(sock,
server_hostname=server_hostname)
try:
if self._check_hostname:
ssl.match_hostname(self.sock.getpeercert(), self.host)