How to update cacerts.txt of httplib2 for Github?

后端 未结 2 1469
面向向阳花
面向向阳花 2020-12-19 08:07

I am trying to use Github API with httplib2. But when I making requests to it\'s endpoints, it gives me following error:

import httplib2
h = httplib2.Http()
         


        
相关标签:
2条回答
  • 2020-12-19 08:44

    just update httplib2 package by

    pip install --upgrade httplib2
    

    or you can replace cacerts.txt this file directly https://github.com/httplib2/httplib2/blob/master/python2/httplib2/cacerts.txt

    also if you use boto.txt file then you might use like boto.txt

    ca_certificates_file = /etc/ssl/certs/ca-bundle.crt <--- location of your system cert
    

    or you can specify your httplib2 cacerts.txt file by

    ca_certificates_file = /usr/local/lib/python2.7/dist-packages/httplib2/python2/httplib2/cacerts.txt
    
    0 讨论(0)
  • 2020-12-19 09:10

    UPD: The easiest way is to open GitHub in Firefox, View Page info -> Security -> View Certificate -> Details -> Export -> As PEM file. And also it is better to use requests.

    From the information which Firefox gives about https connection, I found out that certificate for GitHub is "DigiCert High Assurance EV Root CA", which could be found here: http://curl.haxx.se/ca/cacert.pem

    Text of certificate could be pasted to the httplib2.__path__ + '/cacerts.txt', or saved to separate file and than http connection should be created with:

    h = httplib2.Http(ca_certs='/path/to/that/file')
    

    Here is also useful post about this topic.

    0 讨论(0)
提交回复
热议问题