File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
src/ps_helper/middlewares Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ # LegacyConnectContextFactory
2+
3+ This middleware provides a custom ` ClientContextFactory ` for ** Scrapy** to fix the SSL error:
4+
5+ ` SSL routines: unsafe legacy renegotiation disabled error `
6+
7+ ---
8+
9+ ## Installation
10+
11+ Place the extension in your Scrapy project and enable it in ` settings.py ` :
12+
13+ ``` python
14+ DOWNLOADER_CLIENTCONTEXTFACTORY = " ps_helper.middlewares.LegacyConnectContextFactory"
15+ ```
16+ Scrapy will then use the LegacyConnectContextFactory for all HTTPS connections.
17+
18+ --------------------------------------
Original file line number Diff line number Diff line change 1+ from scrapy .core .downloader .contextfactory import ScrapyClientContextFactory
2+
3+
4+ class LegacyConnectContextFactory (ScrapyClientContextFactory ):
5+ """Solve SSL routines unsafe legacy renegotiation disabled error."""
6+
7+ def getContext (self , hostname = None , port = None ):
8+ ctx = self .getCertificateOptions ().getContext ()
9+ ctx .set_options (0x4 )
10+ return ctx
You can’t perform that action at this time.
0 commit comments