How to update cacerts.txt of httplib2 for Github?

后端 未结 2 1468
面向向阳花
面向向阳花 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 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.

提交回复
热议问题