我们有一个遗留应用程序,它需要 Python 3.2 版才能工作。为此,我们编译并安装Python 3.2 版。
我们能够在Ubuntu 20.04.1 LTS上成功编译和安装 3.2 版 Python ,但是我们开始遇到使用Python“hashlib”库的问题,如下面的摘录所示......
root@sinj:/usr/local/src/lbginst# /usr/local/lb/py32/bin/python3.2 -c "import hashlib;m=hashlib.md5();print(m.hexdigest())"
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type md5
ERROR:root:code for hash sha1 was not found.
Traceback (most recent call last):
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha1
ERROR:root:code for hash sha224 was not found.
Traceback (most recent call last):
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha224
ERROR:root:code for hash sha256 was not found.
Traceback (most recent call last):
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha256
ERROR:root:code for hash sha384 was not found.
Traceback (most recent call last):
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha384
ERROR:root:code for hash sha512 was not found.
Traceback (most recent call last):
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 141, in <module>
globals()[__func_name] = __get_hash(__func_name)
File "/usr/local/lb/py32/lib/python3.2/hashlib.py", line 91, in __get_builtin_constructor
raise ValueError('unsupported hash type %s' % name)
ValueError: unsupported hash type sha512
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'md5'
问题:我们如何解决提出的问题?
注意 I:在互联网上查阅了数十个资源后,我们开始怀疑与libssl.so libcrypto.so二进制文件有关的某些内容。
注二:我们如何诊断正在发生的事情的信息也非常受欢迎!
谢谢!=D
更新:另一个症状是在构建过程中出现此消息(make
,make install
)......
Failed to build these modules:
_hashlib _ssl
您的问题是您使用的是 OpenSSL 1.1 和不支持该版本 OpenSSL 的旧版 Python。Python 3.2 于 2011 年发布,OpenSSL 1.1.0 于 2016 年发布。
由于 OpenSSL 1.0 不再受安全支持,您需要将您正在使用的 Python 版本升级到合适的版本。如果您迫不及待并且计划在接下来的三个月内升级,您还可以使用 Ubuntu 16.04 容器,其中包含 Ubuntu 支持的 OpenSSL 1.0,直到 4 月。但是,Python 3.2 也可能存在未修补的漏洞。
出现指出的问题是因为 python 版本 3.2 与 openssl 版本 1.1 不兼容,openssl 版本是
apt-get
Ubuntu 20.04.1 LTS 使用的标准版本 ( )。解决方案是编译并安装 (
make
,make install
) 版本 1.0 的 openssl,并使用变量“CFLAGS”和“LDFLAGS”配置编译过程,使其使用 openssl 版本 1.0。完毕!谢谢!=D
[参考:https://chowyi.com/%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91%E5%AE%89%E8%A3%85Python3%E5%8F%8A %E9%97%AE%E9%A2%98%E8%A7%A3%E5%86%B3/,https://raspberrypi.stackexchange.com/questions/66782/how-to-install-openssl-1- 0-2-on-raspberry-pi3/66788?newreg=89c76bb5b1f542f88a63268243455e75,https://stackoverflow.com/questions/1904990/what-is-the-difference-between-ld-library-path-and-l-at-链接时间/1905144#1905144,https://stackoverflow.com/questions/22409092/coredump-when-compiling-python-with-a-custom-openssl-version/22409394#22409394,https://stackoverflow.com/问题/5937337/building-python-with-ssl-support-in-non-standard-location/5939170#5939170,https://stackoverflow.com/questions/2537271/compile-openssl-with-the-shared-option/ 23513969#23513969 , https://www.hpc.dtu.dk/?page_id=1180 , https://stackoverflow.com/a/24026737/3223785 , https://www.a2hosting.com/kb/security/ssl/determining-the-openssl-version,https://superuser.com/a/1618761/195840,https://stackoverflow.com/a/46476640/3223785]