SSL Requests for Python and Allow Certificate Encryption

Now I am afraid to get the requests library in order to fulfill a simple GET request to my site with a Allow encryption . Everything is fine with the site, and I can access it from Chrome just fine. (Now I am running OSX El Capitan).

First I tried to make a GET request to the site:

 >>> import requests >>> requests.get('https://example.com') 

This gives me:

 requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590) 

Then I tried various things, including obtaining a certificate Allow privilege encryption , and the following openssl command validates my site certificate successfully

 > openssl s_client -CAfile ./letsencryptauthorityx1.pem -connect example.com:443 

The output of which included the following:

 ... SSL-Session: Protocol : TLSv1 Cipher : DHE-RSA-AES256-SHA Session-ID: ... Session-ID-ctx: Master-Key: ... Key-Arg : None Start Time: 1452865123 Timeout : 300 (sec) Verify return code: 0 (ok) --- 

Perhaps something is missing for me, but it seems to me that my site has been checked in accordance with the Let Encrypt certificate of authority provided by me. So, I happily changed the Python code to:

 >>> requests.get('https://example.com', verify='./letsencryptauthorityx1.pem') 

But I still get requests.exceptions.SSLError error. I also tried using the DER certificate credential format, but then I get the following error from requests :

 requests.exceptions.SSLError: unknown error (_ssl.c:2825) 

Can someone possibly teach me how to fix this?

+6
source share
2 answers

It looks like your CA CERTS on the computer are not updated, or the web server is not configured for the full server certificate chain.

+2
source

In OSX, you can export all certificates to your access to the key chain to the .pem file, and then specify the requests for this file: http://movingpackets.net/2015/03/18/telling-openssl-about-your-root- certificates /

 CA_BUNDLE = path_to_your_exported_file.pem response = requests.get(user_account_url, verify=CA_BUNDLE) 
0
source

All Articles