Tweepy SSLError regarding ssl certificate

后端 未结 5 1205
不思量自难忘°
不思量自难忘° 2021-01-06 05:13

I am running a REST API (Search API) with Tweepy in Python. I worked the program at home and it\'s totally fine. But now I am working on this in different networks and I got

5条回答
  •  -上瘾入骨i
    2021-01-06 06:03

    For anybody that might stumble on this like I did, I had a similar problem because my company was using a proxy, and the SSL check failed while trying to verify the proxy's certificate.

    The solution was to export the proxy's root certificate as a .pem file. Then you can add this certificate to certifi's trust store by doing:

    import certifi
    cafile = certifi.where()
    with open(r, 'rb') as infile:
        customca = infile.read()
    with open(cafile, 'ab') as outfile:
        outfile.write(customca)
    

    You'll have to replace with the path to the exported file. This should allow requests (and tweepy) to successfully validate the certificates.

提交回复
热议问题