0

I am getting [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:646) for python request.get and request.post calls. Previously the above calls were working fine,now we introduced HTTPS redirection in IIS,and we are gettng this error. So I changed the calls from requests.get(url) to requests.get(url, verify=False) and requests.post(url, data=data) to requests.post(url, data=data, verify=False). Then the POST Web APIS are not reachable. Then I tried changing the URL from Http to Https and made verify=false ,in this case the request calls are working fine but am getting warnings like "its better to add certificate verification". I also tried to create an X.509 (.CER) certificate file from Server side certificate option and gave the .cer file path for verify(verify='path\to\cer file),still am geetting "[SSL: CERTIFICATE_VERIFY_FAILED]". Is there anything wrong in this approach. Anyone face this issue earlier? Please share if you have any insights about this issue.

Thanks in advance Susmitha

2 Answers 2

1

This issue not from your code, but from API server's. SSL: CERTIFICATE_VERIFY_FAILED is raised when server's SSL certificate is not verified by CA, as you know, you should add server-side-ssl to your local REQUESTS_CA_BUNDLE.

This link: ssl-cert-verification would be helpful.

Remember you should use .post(verify='/path') to CA_BUNDLE file.

If you are using certificate file like CER file, you can consider doing like this:

s = requests.Session() s.cert = '/path/client.cert' 
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Beomi, Thanks for your reply.What is CA_BUNDLE.Where it will be pointing? If am using cert file then while generating that file i used X.509 (.CER) certificate file from Server side certificate is this ok?
0

Please check the version of openssl which provided by your system, use this cmd:

> openssl version OpenSSL 0.9.8zh 14 Jan 2016 

I fixed this issue just now after I updated the openssl from 2014 version to 2016 version.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.