首页 > 解决方案 > 是否有自签名 SSL 证书的替代方案?

问题描述

我想使用qnm Python 包解决准正常模式(QNM) 。我正在关注 Leo Stein 的论文(2019 年 8 月),他在 Colab 笔记本中使用了 qnm 包。如果我在 Jupyter Notebook 中使用 SageMath 进行相同的计算,则在获取 URL 时会出现以下错误。我不明白实际问题是什么。由于 SageMath 是基于 Python 的,并且 Colab notebook 也是 Jupyter 环境,因此此时出现意外错误。

我的 Ubuntu 20.04 服务器上安装了 OpenSSL 1.1.1(2018 年 9 月 11 日)。我也多次尝试获得自签名证书,但都失败了。我现在累了,我需要一些帮助来消除错误而不签署 SSL 证书(如果有替代方案)。我需要知道问题出在 Sage 还是 Jupyter,因为可以使用 Python 在 Colab 笔记本中轻松获取 URL。

 ?qnm.download_data()
 qnm.download_data()

输出:

Trying to fetch` https://duetosymmetry.com/files/qnm/data-0.4.0.tar.bz2
data-0.4.0.tar.bz2: 0.00B [00:00, ?B/s]

SSLCertVerificationError                  Traceback (most recent call last)
/`home/kamasha/sage/sageinstall/sage-9.1/local/lib/python3.7/urllib/request.py in do_open(self, http_class, req, **http_conn_args)`

     1316                 h.request(req.get_method(), req.selector, req.data, headers,
    -> 1317                           encode_chunked=req.has_header('Transfer-encoding'))
      1318             except OSError as err: # timeout error

   SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)

    URLError                                  Traceback (most recent call last)
    <ipython-input-4-87f2c0b1b969> in <module>()
    
    ----> 1 qnm.download_data()
    
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate `(_ssl.c:1056)>`

我希望这是足够的信息,我尽力说清楚。

标签: jupyter-notebookopensslpython-3.7google-colaboratorysage

解决方案


当 Sage 使用的 Python 没有 SSL 功能时,可能会出现 SSL 错误。

要检查是否是这种情况,请在 Sage 中运行以下命令:

sage: import _ssl

如果出现错误,请在终端中运行以下命令:

$ sage -i openssl
$ sage -f python3

或者如果sage不在您的路径中,请尝试以下操作:

$ cd ~/sage/sageinstall/sage-9.1/
$ ./sage -i openssl
$ ./sage -f python3

下次从源代码构建 Sage 时,您可能希望在系统范围内安装大量依赖项,这样 Sage 就不必构建它们。

也可以通过 Conda 安装 Sage


推荐阅读