Skip to content

Commit a8b4947

Browse files
committed
Merge pull request scrapy#1938 from redapple/https-proxy-connect-sni
Set SNI properly when using CONNECT
2 parents ba6dbad + dcea11a commit a8b4947

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scrapy/core/downloader/handlers/http11.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,15 @@ def processProxyResponse(self, bytes):
122122
"""
123123
self._protocol.dataReceived = self._protocolDataReceived
124124
if TunnelingTCP4ClientEndpoint._responseMatcher.match(bytes):
125-
self._protocol.transport.startTLS(self._contextFactory,
125+
try:
126+
# this sets proper Server Name Indication extension
127+
# but is only available for Twisted>=14.0
128+
sslOptions = self._contextFactory.creatorForNetloc(
129+
self._tunneledHost, self._tunneledPort)
130+
except AttributeError:
131+
# fall back to non-SNI SSL context factory
132+
sslOptions = self._contextFactory
133+
self._protocol.transport.startTLS(sslOptions,
126134
self._protocolFactory)
127135
self._tunnelReadyDeferred.callback(self._protocol)
128136
else:

0 commit comments

Comments
 (0)