Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Set OP_LEGACY_SERVER_CONNECT to support some old servers when using OpenSSL 3.

Andrey Rakhmatullinfb52918d23b3
diff --git a/scrapy/core/downloader/contextfactory.py b/scrapy/core/downloader/contextfactory.py
index 4abde2238..bc6ad34d8 100644
--- a/scrapy/core/downloader/contextfactory.py
+++ b/scrapy/core/downloader/contextfactory.py
@@ -61,7 +61,9 @@ class ScrapyClientContextFactory(BrowserLikePolicyForHTTPS):
# kept for old-style HTTP/1.0 downloader context twisted calls,
# e.g. connectSSL()
def getContext(self, hostname=None, port=None):
- return self.getCertificateOptions().getContext()
+ ctx = self.getCertificateOptions().getContext()
+ ctx.set_options(0x4) # OP_LEGACY_SERVER_CONNECT
+ return ctx
def creatorForNetloc(self, hostname, port):
return ScrapyClientTLSOptions(hostname.decode("ascii"), self.getContext(),