This week I was having an annoying issue trying to use the requests
library from Python – my corporate proxy is doing SSL inspection and HTTPS traffic was failing due to SSL errors.
After some googling, troubleshooting, and head-smashing – I found a solution.
- Download the root certificate for your proxy. In my case the ZScaler root certificate is only available to administrators and I had to ask the IT team for a copy
- Move the file to your local CA certificate store –
/usr/local/share/ca-certificates
- Confirm the file is a
.crt
file. I believe this only matters on Debian systems - Run
sudo update-ca-certificates
- Confirm that the new cert is in your
/etc/ssl/certs
folder
That should be it! From here on you can test with a simple command:python -c 'import requests; r=requests.get('https://google.com');print(r.text)
If you get an error message, you did something wrong. If you get a block of HTML text, you’re good to go!