今天在新的服务器上使用certbot安装证书,出现了如下错误提示: ImportError: ‘pyOpenSSL’ module missing required functionality. Try upgrading to v0.14 or newer.
错误相关跟踪栈信息为:
Traceback (most recent call last):
File "/usr/bin/certbot", line 9, in <module>
load_entry_point('certbot==0.13.0', 'console_scripts', 'certbot')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/certbot/main.py", line 17, in </module><module>
from certbot import client
File "/usr/lib/python2.7/site-packages/certbot/client.py", line 10, in </module><module>
from acme import client as acme_client
File "/usr/lib/python2.7/site-packages/acme/client.py", line 31, in </module><module>
requests.packages.urllib3.contrib.pyopenssl.inject_into_urllib3() # type: ignore
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 112, in in
ject_into_urllib3
_validate_dependencies_met()
File "/usr/lib/python2.7/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 147, in _v
alidate_dependencies_met
raise ImportError("'pyOpenSSL' module missing required functionality. "
ImportError: 'pyOpenSSL' module missing required functionality. Try upgrading to v0.14 or newer.
</module>
使用最后一行的信息在搜索引擎上找问题,发现github上已经有相关的issue。主要原因是RHEL/CentOS的官方源和epel源的pyOpenSSL版本太旧了,新版的certbot依赖于高版本的pyOpenSSL库,从而失败。参与讨论的部分人指出: 这是(CentOS)系统的问题而非certbot的问题。
issue中提出的解决方案包括: 限定pyOpenSSL的版本: pip install pyOpenSSL=0.13.1, 测试失败;作者建议使用epel-testing库中的v0.13版本,但实测开启epel-testing源安装v0.13版本存在同样的问题。
如何解决这个突然的错误?想到certbot是python程序,从pip安装或许能够绕过系统的pyOpenSSL限制。以下是解决问题的尝试过程: