2

I am hosting a site using SSL / HTTPS, and am attempting to make a request to it from a Python 2.7 script on the server (Ubuntu 18.04).

When running the script, I get this error:

requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)

However, when I run curl --verbose -X GET -I <url> on the same server, it says the certificate was verified.

I do know that the cert is in fact valid and is not a self signed cert.

Any ideas on what I can do to get python to accept that cert?

Edit: here's the code to trigger the issue. Note that I'm not including the URL as it is not accessible to the general public:

import requests
r = requests.get('https://www.example.org')
print r.status_code
Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
Dan
  • 33
  • 4
  • There are many similar question with this kind of error. Unfortunately your question is missing essential details which are needed to reproduce and debug your problem, specifically the exact URL and code which triggers the problem. – Steffen Ullrich Apr 02 '20 at 15:58
  • @SteffenUllrich - The URL is only accessible from company computers. Also, I just added the code that triggers the issue – Dan Apr 02 '20 at 17:39
  • 1
    *"The URL is only accessible from company computers"* - in this case I speculate that it is a a company internal domain where the certificate is issued by a company specific CA. And that this CA is installed on your computer on the standard path used by OpenSSL, so that curl will find it. But `requests` does not use this path. Try to use `requests.get('https://...', verify='/etc/ssl/certs/ca-certificates.crt')` – Steffen Ullrich Apr 02 '20 at 17:48

0 Answers0