Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在请求中添加可选CA捆绑包_Python_Ssl_Python Requests - Fatal编程技术网

Python 如何在请求中添加可选CA捆绑包

Python 如何在请求中添加可选CA捆绑包,python,ssl,python-requests,Python,Ssl,Python Requests,我需要从python访问一个API,该API在进行TLS连接时不提供正确的捆绑包。我找到了一个有效的方法,但是我认为它不稳定。 假设api.example.org是损坏的设置,证书来自CA1,而www.example.org是正确的设置,但证书来自CA2 以下作品 requests.get('https://api.example.org/', verify='/path/to/CA1_BUNDLE') requests.get('https://www.example.org/') 但这不起

我需要从python访问一个API,该API在进行TLS连接时不提供正确的捆绑包。我找到了一个有效的方法,但是我认为它不稳定。 假设api.example.org是损坏的设置,证书来自CA1,而www.example.org是正确的设置,但证书来自CA2

以下作品

requests.get('https://api.example.org/', verify='/path/to/CA1_BUNDLE')
requests.get('https://www.example.org/')
但这不起作用:-

requests.get('https://www.example.org/', verify='/path/to/CA1_BUNDLE')
这意味着,如果存在
verify='/path/to/CA1\u BUNDLE'
,则它只针对特定的CA进行验证,而不针对我的系统中安装的任何其他CA进行验证。如果api.example.org修复了它们的垃圾,并从不同的CA获得了证书,那么我在生产中的代码将停止工作

这是一种在进行验证时告诉请求使用系统证书以及path/to/CA1\u BUNDLE的方法吗

PS:请不要建议我使用
verify=false
。这是2016年,而不是2008年


更新:我不再需要工作了,有问题的网站修复了他们的垃圾。不过,出于好奇,我们还是希望有一个优雅的解决方案。

将所有其他(系统)CA添加到/path/to/CA1_bundle中的bundle中。@SteffenUllrich:这使得维护工作量大大增加,因为目前我的发行版为我管理系统CA。