How to Get Python Requests to Trust a Self Signed Ssl Certificate

How to get Python requests to trust a self signed SSL certificate?

try:

r = requests.post(url, data=data, verify='/path/to/public_key.pem')

Verify SSL certificate with Requests

To make requests not complain about valid certificate, the certificate supplied to verify= must contain any intermediate certificates. To download full chain, you can use Firefox (screenshots):

Click on page info:

Sample Image



Then download full PEM chain:

Sample Image

How to get ca certificates for python requests?

Correct command to import cacerts using python that worked for me is :

openssl s_client -showcerts -connect myhost.comapny.com:8443 </dev/null 2>/dev/null > company.ca 

Then i supplied "company.ca" path, to the requests as a parameter to specify cacaert location.



Related Topics



Leave a reply



Submit