How to force requests to use certificates on my ubuntu system

I use a self-signed certificate for the purpose of debugging.

$ cp hbrls-server.cert /usr/local/share/ca-certificates/ $ update-ca-certificates 

After that, I see hbrls-server.pem in /etc/ssl/certs/ . But requests still raises an SSLError.

If I specify cert like this: requests.get('https://blabla', verify='/etc/ssl/certs/hbrls-server.pem') , it will be OK.

And python -m requests.certs returns /usr/local/lib/python2.7/dist-packages/certifi/cacert.pem .

How can I use requests to use certificates in the system. I am working on dockerize sth and would not want to see verify=path-to-cert in my code.

EDIT: ubuntu 12.04, python 2.7.3, requests 2.7.0

+5
source share
1 answer

You can set the environment variable REQUESTS_CA_BUNDLE , so you do not need to change the code:

 export REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/hbrls-server.cert 

Source: http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification

+3
source

All Articles