TnT*_*ech 2 openssl macports hashlib python-3.x
运行 MacOS 10.14.6。刚刚运行 MacPorts 更新。采用 Python 3.9.7 -> 3.9.8 和 OpenSSL 1.1.3 -> 3。
运行现有的 Python 代码表明有些东西出问题了hashlib,RIPEMD160 不再可用(Whirlpool 也可能还有其他摘要)。
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 160, in __hash_new
return _hashlib.new(name, data, **kwargs)
ValueError: [digital envelope routines] initialization error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testhash.py", line 3, in <module>
r160 = hashlib.new('ripemd160')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type ripemd160
Run Code Online (Sandbox Code Playgroud)
可以简单地复制
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 160, in __hash_new
return _hashlib.new(name, data, **kwargs)
ValueError: [digital envelope routines] initialization error
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "testhash.py", line 3, in <module>
r160 = hashlib.new('ripemd160')
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type ripemd160
Run Code Online (Sandbox Code Playgroud)
该方法hashlib.algorithms_available表明hashlibthinkripemd160 可用:
Available: {'sha512', 'shake_128', 'ripemd160', 'sha224', 'md5', 'whirlpool', 'blake2b', 'sha3_512', 'md4', 'sha3_256', 'sha256', 'shake_256', 'md5-sha1', 'sha1', 'sha512_224', 'sm3', 'mdc2', 'blake2s', 'sha3_384', 'sha3_224', 'sha512_256', 'sha384'}
Guaranteed: {'sha3_512', 'sha512', 'sha1', 'shake_128', 'sha3_384', 'sha224', 'md5', 'sha256', 'sha3_224', 'sha3_256', 'shake_256', 'blake2b', 'blake2s', 'sha384'}
Run Code Online (Sandbox Code Playgroud)
并且询问openssl证实它确实具有这种能力。
回滚,同样的问题。我更愿意保留最新的安装。使用 RIPEMD160 是没有商量余地的。
我怀疑提供ports正确的开关、命令、环境变量将说服重新编译工作,但我不知道是什么。
关于发生了什么、如何解决有什么想法吗?
所有旧的加密功能仍然存在于 OpenSSL3 中,但现在需要手动启用。有关详细信息,请参阅OpenSSL github 项目的问题 16994。
要快速启用它,请通过运行以下命令找到保存 OpenSSL 配置文件或其符号链接的目录:
openssl version -d
Run Code Online (Sandbox Code Playgroud)
您现在可以转到该目录并编辑配置文件(可能需要使用 sudo):
nano openssl.cnf
Run Code Online (Sandbox Code Playgroud)
确保配置文件包含以下行:
openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
default = default_sect
legacy = legacy_sect
[default_sect]
activate = 1
[legacy_sect]
activate = 1
Run Code Online (Sandbox Code Playgroud)
测试环境:OpenSSL 3.0.2、Python 3.10.4、Linux Ubuntu 22.04 LTS aarch64,目前我无法访问其他平台。
| 归档时间: |
|
| 查看次数: |
3498 次 |
| 最近记录: |