python - 在python中将服务器证书添加到CA_BUNDLE

标签 python ssl https python-requests client-certificates

我正在使用请求通过 https 与远程服务器进行通信。目前我没有验证 SSL 证书,我想解决这个问题。

在请求文档中,我发现:

You can pass verify the path to a CA_BUNDLE file with certificates of trusted CAs. This list of trusted CAs can also be specified through the REQUESTS_CA_BUNDLE environment variable.

我不想使用系统的证书,而是想生成我自己的商店。

到目前为止,我正在使用 ssl.get_server_certificate(addr) 获取服务器证书,但我不知道如何创建自己的商店并将其添加到那里。

最佳答案

这实际上是微不足道的... CA_BUNDLE 可以是您附加证书的任何文件,因此您只需将 ssl.get_server_certificate() 的输出附加到该文件即可工作。

关于python - 在python中将服务器证书添加到CA_BUNDLE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31369633/

相关文章:

facebook - iframe 中的 SSL 页面和非安全内容?

java - 即使我已经添加了证书,如何修复 javax.net.ssl.SSLHandshakeException

javascript - 在关闭或已经关闭的模式下保护 websocket

Firefox 不信任自签名证书

python - 导入错误 : Module "whitenoise.middleware" does not define a "WhiteNoiseMiddleWare" attribute/class

python - SQLAlchemy session 的上下文/范围是否需要非自动对象/属性过期?

python - 如何在 python 3.x 中检索和显示 Vimeo 视频的 JSON 数据?

javascript - 我可以使用 TLS 加密 Node.js TCP 流量以使其无法读取吗?

.htaccess - 尝试将目录重定向到 https 但在返回时得到双 URL 段

python - 在 nltk.tree.Tree 中查找路径