diff --git a/scrapy/core/downloader/handlers/http11.py b/scrapy/core/downloader/handlers/http11.py index 9cb659e67..4a0612cdf 100644 --- a/scrapy/core/downloader/handlers/http11.py +++ b/scrapy/core/downloader/handlers/http11.py @@ -122,7 +122,10 @@ class TunnelingTCP4ClientEndpoint(TCP4ClientEndpoint): """ self._protocol.dataReceived = self._protocolDataReceived if TunnelingTCP4ClientEndpoint._responseMatcher.match(bytes): - self._protocol.transport.startTLS(self._contextFactory, + # this set proper Server Name Indication extension + sslOptions = self._contextFactory.creatorForNetloc( + self._tunneledHost, self._tunneledPort) + self._protocol.transport.startTLS(sslOptions, self._protocolFactory) self._tunnelReadyDeferred.callback(self._protocol) else: