import requests data = {'foo':'bar'} url = 'https://foo.com/bar' r = requests.post(url, data=data)
If the URL uses a self signed certificate, this fails with
requests.exceptions.SSLError: [Errno 1] _ssl.c:507: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
I know that I can pass False
to the verify
parameter, like this:
r = requests.post(url, data=data, verify=False)
However, what I would like to do is point requests to a copy of the public key on disk and tell it to trust that certificate.
You must manually turn on trust for SSL/TLS when you install a profile that is sent to you via email or downloaded from a website. If you want to turn on SSL/TLS trust for that certificate, go to Settings > General > About > Certificate Trust Settings.
Requests verifies SSL certificates for HTTPS requests, just like a web browser. SSL Certificates are small data files that digitally bind a cryptographic key to an organization's details.
try:
r = requests.post(url, data=data, verify='/path/to/public_key.pem')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With