繁体   English   中英

Python:未定义符号:导入 ssl 时的 TLSv1_method

[英]Python: undefined symbol: TLSv1_method when importing ssl

我在一个发行版上运行 Python 3.5.6,其中 TLS 版本低于 1.2 已通过将这些选项传递给no-ssl no-tls1 no-tls1_1 no-ssl3-method no-tls1-method no-tls1_1-method编译出来。 no-ssl no-tls1 no-tls1_1 no-ssl3-method no-tls1-method no-tls1_1-method OpenSSL 版本为 1.1.1d。 Python 3 在发行版构建时从源代码构建,并与发行版中包含的 OpenSSL 版本相关联。

一切构建成功,但是当我尝试在 Python 中导入ssl库时,出现以下错误:

$ 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.
>>> import ssl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/ssl.py", line 99, in <module>
    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

我不明白为什么在运行时会发生此错误。 我在 TLSv1_method 的 Python 3.5.6 代码中可以找到的唯一参考是 _ssl.c 的第 3088 行:

ctx = SSL_CTX_new(TLSv1_method());

使用no-tls1-method确实编译出TLSv1_method的实现,并且 Python 代码中的那一行不受任何#ifdef保护。 但我希望这会导致_ssl.cpython-35m-aarch64-linux-gnu.so模块在链接时失败,而不是在 Python 尝试导入模块时在运行时失败。 这是怎么回事,有没有办法在不修补 Python 的情况下修复它? 我无法升级正在使用的 OpenSSL 或 Python 的版本。

似乎我的困惑是由于误解_ssl.cpython-35m-aarch64-linux-gnu.so如何链接到 OpenSSL。 我假设它是静态链接的,但它实际上是动态链接到libssl.so的。 这就是为什么在加载共享 object 时在运行时发生错误的原因。

那么,在不更新 Python 的情况下解决此问题的唯一方法似乎是修补对TLSv1_method的调用以改用通用TLS_method 我会把这个问题留几天,但万一有人有更好的建议。

编辑:我为此问题提交了Python 错误 它应该在未来的版本中得到修复。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM