Facebook graph GET request using the certificate certificate certificate python request module

I am writing a short python script for fun, to check a few pages for the number I like. I am using python query module. As you can see below, there was a problem, something about certificates. I am new to network programming, so it’s not clear to me what I should do. r = requests.get("http://www.google.com/") returned something correctly.

Traceback (last last call): r = request.get (" https://graph.facebook.com/cocacola ") routines: SSL3_GET_SERVER_CERTIFICATE: certificate failed

Thank!

+3
python facebook-graph-api python-requests
Jan 27 '12 at 9:31
source share
2 answers

This error appears to be coming from OpenSSL. You may have some kind of configuration in your environment that forces Requests to set the location of the certificate to something that does not contain the required certificate.

Try exploring possible ways to verify certificate requests:

  • It searches for a configuration using the REQUESTS_CA_BUNDLE environment variable.
  • It verifies curl compliance using the CURL_CA_BUNDLE environment CURL_CA_BUNDLE .
  • It tries to import the certifi list if the certifi package can be imported.

Check if one of REQUESTS_CA_BUNDLE or CURL_CA_BUNDLE is in your environment:

 env | egrep "REQUESTS_CA_BUNDLE|CURL_CA_BUNDLE" 

If one of them is installed, requests are likely to use this configuration when verifying certificates. If not, then the requests probably use certifi . In this case, it might be worth updating it:

 pip install -U certifi 

Otherwise, try passing verify=False to requests.get so that it skips the verification step. I would recommend solving the real problem, and not just turning it off, but it can help you figure it out.

+3
Jan 27 '12 at 10:11
source share

Have you installed certifi ? A similar problem also burned me. Due to GPL licensing issues, Kenneth Reitz and Co. had to move the SSL license package to another repo.

I just tried the following with the most updated certifi from pypi installed and it seems to work fine:

 >>> import requests >>> r = requests.get("https://graph.facebook.com/cocacola") >>> r <Response [200]> 

More information on licensing issues is available in this Github Issue thread ( Full Dissolma . I was the original poster for this thread).

If the new certifi doesn't fix it, you can try the Github request page . They are a very responsive and friendly community!

Edit: if updated certifi doesn't fix it, I highly recommend another poster suggestion try verify=False

+2
Jan 27 2018-12-12T00:
source share



All Articles