Skip to content

Commit dcea11a

Browse files
committed
Fall back to no-SNi context factory is Twisted<14 is used
1 parent d6760db commit dcea11a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scrapy/core/downloader/handlers/http11.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ def processProxyResponse(self, bytes):
122122
"""
123123
self._protocol.dataReceived = self._protocolDataReceived
124124
if TunnelingTCP4ClientEndpoint._responseMatcher.match(bytes):
125-
# this set proper Server Name Indication extension
126-
sslOptions = self._contextFactory.creatorForNetloc(
127-
self._tunneledHost, self._tunneledPort)
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
128133
self._protocol.transport.startTLS(sslOptions,
129134
self._protocolFactory)
130135
self._tunnelReadyDeferred.callback(self._protocol)

0 commit comments

Comments
 (0)