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.
Setting
export SSL_CERT_FILE=/path/file.crt
should do the job.You may try:
You can read more here: http://docs.python-requests.org/en/master/user/advanced/
try:
The easiest is to export the variable
REQUESTS_CA_BUNDLE
that points to your private certificate authority, or a specific certificate bundle. On the command line you can do that as follows:If you have your certificate authority and you don't want to type the
export
each time you can add theREQUESTS_CA_BUNDLE
to your~/.bash_profile
as follows:Case where multiple certificates are needed was solved as follows: Concatenate the multiple root pem files, myCert-A-Root.pem and myCert-B-Root.pem, to a file. Then set the requests REQUESTS_CA_BUNDLE var to that file in my ./.bash_profile.
With the
verify
parameter you can provide a custom certificate authority bundle (http://docs.python-requests.org/en/latest/user/advanced/):