title: Python: undefined symbol: TLSv1_method when importing ssl
body: <p>I'm running Python 3.5.6 on a distribution where TLS versions below 1.2 have been compiled out of OpenSSL by passing these options to ./configure: <code>no-ssl no-tls1 no-tls1_1 no-ssl3-method no-tls1-method no-tls1_1-method</code>. The OpenSSL version is 1.1.1d. Python 3 is built from source at distro build time and linked against the version of OpenSSL included in the distro.</p>
  
  <p>Everything builds successfully, but when I try to import the <code>ssl</code> library in Python, I get the following error:</p>
  
  <pre><code>$ python3
  Python 3.5.6 (default, Mar 23 2020, 05:11:33)
  [GCC 8.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import ssl
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python3.5/ssl.py", line 99, in &lt;module&gt;
      import _ssl             # if we can't import it, let the error propagate
  ImportError: /usr/lib/python3.5/lib-dynload/_ssl.cpython-35m-aarch64-linux-gnu.so: undefined symbol: TLSv1_method
  </code></pre>
  
  <p>I don't understand why this error occurs at runtime. The only reference I can find in the Python 3.5.6 code to TLSv1_method is line 3088 of _ssl.c:</p>
  
  <pre><code>ctx = SSL_CTX_new(TLSv1_method());
  </code></pre>
  
  <p>Using <code>no-tls1-method</code> does compile out the implementation of <code>TLSv1_method</code>, and that line in the Python code is not guarded by any <code>#ifdef</code>. But I'd expect that to cause a failure at link time for the <code>_ssl.cpython-35m-aarch64-linux-gnu.so</code> module, not at runtime when Python tries to import the module. What's going on here, and is there a way to fix it without patching Python? I cannot upgrade the version of OpenSSL or Python in use.</p>