<h3 dir="auto">Description</h3>
<p dir="auto">Running on MacOS 12.2.1,<br>
Scrapy 2.6.2 breaks with SSL error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
2022-09-26 15:22:01 [twisted] CRITICAL: 
Traceback (most recent call last):
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/twisted/internet/defer.py&quot;, line 1696, in _inlineCallbacks
    result = context.run(gen.send, result)
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/crawler.py&quot;, line 101, in crawl
    self.engine = self._create_engine()
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/crawler.py&quot;, line 115, in _create_engine
    return ExecutionEngine(self, lambda _: self.stop())
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/engine.py&quot;, line 83, in __init__
    self.downloader = downloader_cls(crawler)
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/__init__.py&quot;, line 83, in __init__
    self.middleware = DownloaderMiddlewareManager.from_crawler(crawler)
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/middleware.py&quot;, line 59, in from_crawler
    return cls.from_settings(crawler.settings, crawler)
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/middleware.py&quot;, line 40, in from_settings
    mwcls = load_object(clspath)
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/utils/misc.py&quot;, line 61, in load_object
    mod = import_module(module)
  File &quot;/Users/barney/.pyenv/versions/3.10.2/lib/python3.10/importlib/__init__.py&quot;, line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1050, in _gcd_import
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1027, in _find_and_load
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1006, in _find_and_load_unlocked
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 688, in _load_unlocked
  File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 883, in exec_module
  File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 241, in _call_with_frames_removed
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/downloadermiddlewares/retry.py&quot;, line 27, in &lt;module&gt;
    from scrapy.core.downloader.handlers.http11 import TunnelError
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/handlers/http11.py&quot;, line 23, in &lt;module&gt;
    from scrapy.core.downloader.contextfactory import load_context_factory_from_settings
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/contextfactory.py&quot;, line 11, in &lt;module&gt;
    from scrapy.core.downloader.tls import DEFAULT_CIPHERS, openssl_methods, ScrapyClientTLSOptions
  File &quot;/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/tls.py&quot;, line 23, in &lt;module&gt;
    METHOD_SSLv3: SSL.SSLv3_METHOD,                     # SSL 3 (NOT recommended)
AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv3_METHOD'"><pre class="notranslate"><code class="notranslate">
2022-09-26 15:22:01 [twisted] CRITICAL: 
Traceback (most recent call last):
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/twisted/internet/defer.py", line 1696, in _inlineCallbacks
    result = context.run(gen.send, result)
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/crawler.py", line 101, in crawl
    self.engine = self._create_engine()
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/crawler.py", line 115, in _create_engine
    return ExecutionEngine(self, lambda _: self.stop())
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/engine.py", line 83, in __init__
    self.downloader = downloader_cls(crawler)
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/__init__.py", line 83, in __init__
    self.middleware = DownloaderMiddlewareManager.from_crawler(crawler)
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/middleware.py", line 59, in from_crawler
    return cls.from_settings(crawler.settings, crawler)
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/middleware.py", line 40, in from_settings
    mwcls = load_object(clspath)
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/utils/misc.py", line 61, in load_object
    mod = import_module(module)
  File "/Users/barney/.pyenv/versions/3.10.2/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "&lt;frozen importlib._bootstrap&gt;", line 1050, in _gcd_import
  File "&lt;frozen importlib._bootstrap&gt;", line 1027, in _find_and_load
  File "&lt;frozen importlib._bootstrap&gt;", line 1006, in _find_and_load_unlocked
  File "&lt;frozen importlib._bootstrap&gt;", line 688, in _load_unlocked
  File "&lt;frozen importlib._bootstrap_external&gt;", line 883, in exec_module
  File "&lt;frozen importlib._bootstrap&gt;", line 241, in _call_with_frames_removed
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/downloadermiddlewares/retry.py", line 27, in &lt;module&gt;
    from scrapy.core.downloader.handlers.http11 import TunnelError
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/handlers/http11.py", line 23, in &lt;module&gt;
    from scrapy.core.downloader.contextfactory import load_context_factory_from_settings
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/contextfactory.py", line 11, in &lt;module&gt;
    from scrapy.core.downloader.tls import DEFAULT_CIPHERS, openssl_methods, ScrapyClientTLSOptions
  File "/Users/barney/git/netail_code/netail-crawling-infra/crawling/netail-crawler/.venv/lib/python3.10/site-packages/scrapy/core/downloader/tls.py", line 23, in &lt;module&gt;
    METHOD_SSLv3: SSL.SSLv3_METHOD,                     # SSL 3 (NOT recommended)
AttributeError: module 'OpenSSL.SSL' has no attribute 'SSLv3_METHOD'
</code></pre></div>
<p dir="auto">I suspect this error is because PyOpenSSL pushed a new release that pins to <code class="notranslate">cryptography&gt;=38.0.0,&lt;39</code> (see: <a href="https://github.com/pyca/pyopenssl/pull/1150/files">https://github.com/pyca/pyopenssl/pull/1150/files</a>, and <a href="https://github.com/pyca/pyopenssl/blob/main/setup.py#L99">https://github.com/pyca/pyopenssl/blob/main/setup.py#L99</a>), as downgrading to <code class="notranslate">cryptography&gt;38</code> removes this error entirely.</p>
<h3 dir="auto">Steps to Reproduce</h3>
<ol dir="auto">
<li>Install scrapy == 2.6.2 on fresh virtualenv</li>
<li>Run scrapy</li>
<li>See error</li>
<li>Downgrade cryptography&lt;38</li>
<li>Error goes.</li>
</ol>
<p dir="auto"><strong>Expected behavior:</strong> [What you expect to happen]</p>
<p dir="auto"><strong>Actual behavior:</strong> [What actually happens]</p>
<p dir="auto"><strong>Reproduces how often:</strong> [What percentage of the time does it reproduce?]</p>
<h3 dir="auto">Versions</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=".venv ❯ scrapy version --verbose
Scrapy       : 2.6.2
lxml         : 4.9.1.0
libxml2      : 2.9.4
cssselect    : 1.1.0
parsel       : 1.6.0
w3lib        : 2.0.1
Twisted      : 22.8.0
Python       : 3.10.2 (main, Mar 25 2022, 12:18:40) [Clang 13.1.6 (clang-1316.0.21.2)]
pyOpenSSL    : 22.1.0 (OpenSSL 3.0.5 5 Jul 2022)
cryptography : 38.0.1
Platform     : macOS-12.2.1-arm64-arm-64bit"><pre class="notranslate"><code class="notranslate">.venv ❯ scrapy version --verbose
Scrapy       : 2.6.2
lxml         : 4.9.1.0
libxml2      : 2.9.4
cssselect    : 1.1.0
parsel       : 1.6.0
w3lib        : 2.0.1
Twisted      : 22.8.0
Python       : 3.10.2 (main, Mar 25 2022, 12:18:40) [Clang 13.1.6 (clang-1316.0.21.2)]
pyOpenSSL    : 22.1.0 (OpenSSL 3.0.5 5 Jul 2022)
cryptography : 38.0.1
Platform     : macOS-12.2.1-arm64-arm-64bit
</code></pre></div>
<h3 dir="auto">Additional context</h3>
<p dir="auto">Any additional information, configuration, data or output from commands that might be necessary to reproduce or understand the issue. Please try not to include screenshots of code or the command line, paste the contents as text instead. You can use <a href="https://help.github.com/en/articles/creating-and-highlighting-code-blocks">GitHub Flavored Markdown</a> to make the text look better.</p>
<p dir="auto"><a href="https://github.com/scrapy/scrapy/blob/1.5.0/scrapy/core/downloader/tls.py#L17">WHAT THE F</a></p>
<p dir="auto">does not exist in pyopenssl</p>
<p dir="auto">no help anywhere</p>