Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.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 pycurl https错误:无法获取本地颁发者证书_Python_Windows_Ssl_Ssl Certificate_Pycurl - Fatal编程技术网

Python pycurl https错误:无法获取本地颁发者证书

Python pycurl https错误:无法获取本地颁发者证书,python,windows,ssl,ssl-certificate,pycurl,Python,Windows,Ssl,Ssl Certificate,Pycurl,导入pycurl >>>c=pycurl.Curl() >>>c.setopt(c.URL,'https://quora.com') >>>c.执行 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 pycurl.error:(60,“SSL证书问题:无法获取本地颁发者证书”) >>> >>>c.setopt(c.URL,'http://quora.com') >>>c.执行 >>> >>> 为什么无法获取本地颁发者证书?我如何解决这个问题?当我在浏览器中打开quora.com时,我看到它

导入pycurl >>>c=pycurl.Curl() >>>c.setopt(c.URL,'https://quora.com') >>>c.执行 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 pycurl.error:(60,“SSL证书问题:无法获取本地颁发者证书”) >>> >>>c.setopt(c.URL,'http://quora.com') >>>c.执行 >>> >>> 为什么无法获取本地颁发者证书?我如何解决这个问题?当我在浏览器中打开quora.com时,我看到它的身份已被验证。为什么会这样?如何让pycurl使用浏览器使用的相同证书?
问题在于
pycurl
需要最新的证书链来验证ssl证书

一个好的解决办法是使用

它基本上是mozilla内置证书链的最新副本,封装在python包中,可以使用pip保持最新
certifi.where()
提供证书捆绑包的位置

要使
pycurl
使用它,请设置
CAINFO
选项:

>>> import pycurl
>>> c = pycurl.Curl()
>>> c.setopt(c.URL, 'https://quora.com')
>>> c.perform()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pycurl.error: (60, 'SSL certificate problem: unable to get local issuer certificate')
>>>
>>> c.setopt(c.URL, 'http://quora.com')
>>> c.perform()
>>>
>>>
相关的:
import pycurl
import certifi

curl = pycurl.Curl()
curl.setopt(pycurl.CAINFO, certifi.where())
curl.setopt(pycurl.URL, 'https://www.quora.com')
curl.perform()