python - (安装Python 3.6.1) SSLError : SSL: TLSV1_ALERT_UNKNOWN_CA tlsv1 alert unknown ca

标签 python python-3.x ubuntu ssl openssl

我正在尝试在 Ubuntu 16.10 上从源代码安装 Python 3.6。

make test

当我进行测试时,安装会引发一个错误提示......

======================================================================
ERROR: test_logincapa_with_client_certfile (test.test_imaplib.RemoteIMAP_SSLTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/anderson/Downloads/Python-3.6.1/Lib/test/test_imaplib.py", line 973, in test_logincapa_with_client_certfile
    certfile=CERTFILE)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1280, in __init__
    IMAP4.__init__(self, host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 197, in __init__
    self.open(host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1293, in open
    IMAP4.open(self, host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 294, in open
    self.sock = self._create_socket()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1285, in _create_socket
    server_hostname=self.host)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 808, in __init__
    self.do_handshake()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:749)

======================================================================
ERROR: test_logincapa_with_client_ssl_context (test.test_imaplib.RemoteIMAP_SSLTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/anderson/Downloads/Python-3.6.1/Lib/test/test_imaplib.py", line 979, in test_logincapa_with_client_ssl_context
    self.host, self.port, ssl_context=self.create_ssl_context())
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1280, in __init__
    IMAP4.__init__(self, host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 197, in __init__
    self.open(host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1293, in open
    IMAP4.open(self, host, port)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 294, in open
    self.sock = self._create_socket()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/imaplib.py", line 1285, in _create_socket
    server_hostname=self.host)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 401, in wrap_socket
    _context=self, _session=session)
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 808, in __init__
    self.do_handshake()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 1061, in do_handshake
    self._sslobj.do_handshake()
  File "/home/anderson/Downloads/Python-3.6.1/Lib/ssl.py", line 683, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:749)

----------------------------------------------------------------------
Ran 95 tests in 21.126s

FAILED (errors=2)
test test_imaplib failed
1 test failed again:
    test_imaplib

Total duration: 3 min 9 sec
Tests result: FAILURE
Makefile:1018: recipe for target 'test' failed
make: *** [test] Error 1

有什么问题吗?

最佳答案

您指定的这段代码似乎不存在于以前或更新的分支中。

但是这个特定错误表示 CA 不是有效(受信任的)CA。

查看具体代码,发现 key 似乎是lib/test文件夹下的keycert3.pem。

CA文件是pycacert.pem,你可以添加这个CA让你的机器信任。您可以在 super 用户上看到答案,例如 https://superuser.com/questions/437330/how-do-you-add-a-certificate-authority-ca-to-ubuntu

虽然我似乎记得只需将文件复制到/etc/ssl/certs 中就足够了,但它指定了如何操作。 希望对您有所帮助。

关于python - (安装Python 3.6.1) SSLError : SSL: TLSV1_ALERT_UNKNOWN_CA tlsv1 alert unknown ca,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43738038/

相关文章:

python - 通过 SOCKs 代理请求

python - 将误差线添加到 Pandas 中的分组条形图

python - 在 DjangoRestFramework 中没有键的情况下返回 'ReturnList' 的值

python-3.x - 如何在 Holoviews 中设置事件工具

node.js - 使用 chef 在 aws 上安装 node.js 的正确方法

ubuntu - 通过用户类分配 ISC-DHCP-Server IP 池

python - 我可以将什么附加到 Pylons 中的 pylons.request 上?

python - Lua脚本不会执行python脚本

python - 如何使用 pandas 将具有多个值的字段解压到行中

linux - 我需要安装什么才能使用 fwupd 更新我的计算机固件?