【发布时间】:2017-12-12 21:39:38
【问题描述】:
所以我整晚都在做这个,我似乎无法解决它。
问题是我无法在 Python3 中建立 https 连接。一个基本的例子:
import urllib3
http = urllib3.PoolManager()
http.request("GET", "https://community.letsencrypt.org/")
结果如下:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
<urllib3.response.HTTPResponse object at 0x103844d30>
这对https://google.com 给出了相同的结果,但有两次,我假设是因为重定向。
- 我已经安装了 certifi 包
- 我已经运行了 Install Certificates.command
- 我已经重新安装了python3(我使用自制软件)
- 我已经检查了 cert.pem 链接,
- 我已经安装了 python.org python3 包(看看是不是自制的)
- 我检查了 /usr/local/etc/openssl/cert.pem(自制软件)和 /Library/Frameworks/Python.framework/Versions/3.6/etc/openssl/cert 中的 cert.pem 链接是否正确.pem(python.org 本地安装)
我最好的猜测是它找不到根证书,但它们就在那里,新安装的 certifi 包
我最初的工作是让 mqtt 通过 ssl 连接再次工作。
【问题讨论】:
-
你不能只使用请求吗?它解决了 95% 的此类问题。
-
很遗憾,没有。由于 paho-mqtt 不使用它(这是我的目标)
标签: python python-3.x https