首页 > 解决方案 > 使用 sphinx 生成文档时如何禁用 ssl 验证?(在代理后面工作)

问题描述

生成文档会给我以下错误:

loading intersphinx inventory from https://docs.python.org/3/objects.inv...
WARNING: failed to reach any of the inventories with the following issues:
intersphinx inventory 'https://docs.python.org/3/objects.inv' not fetchable due to <class 'requests.exceptions.SSLError'>: HTTPSConnectionPool(host='docs.python.org', port=443): Max retries exceeded with url: /3/objects.inv (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

我在公司代理后面工作。

有什么办法可以禁用 ssl 验证?就像 anaconda 一样:conda config --set ssl_verify false?

标签: pythonsslproxypython-sphinx

解决方案


根据 Sphinx 文档,您可以修改其中的两个变量之一conf.py以指定证书的路径或一起关闭验证。

  1. tls_verify(boolean) - 如果为真,Sphinx 验证服务器认证LINK
  2. tls_cacert(str) - CA 证书文件的路径或包含证书的目录的路径LINK

它看起来像你的conf.py

# uncomment this if you don't want to verify at all
# tls_verify = False

tls_cacert = "/path/to/cert"

推荐阅读