>>> 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()
>>>
>>>
Why is it unable to get local issuer certificate? How do I solve this? When I open quora.com in my browser, I see that its identity is verified. Why is this the case? How do I get pycurl to use the same certificates my browser uses?
The problem is that pycurl
needs an up-to-date certificate chain to verify the ssl certificates.
A good solution would be to use certifi.
It's basically an up-to-date copy of mozilla's built in certificate chain wrapped in a python package which can be kept up to date using pip. certifi.where()
gives you the location to the certificate bundle.
To make pycurl
to use it, set the CAINFO
option:
import pycurl
import certifi
curl = pycurl.Curl()
curl.setopt(pycurl.CAINFO, certifi.where())
curl.setopt(pycurl.URL, 'https://www.quora.com')
curl.perform()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With