1

I have tried to use request:

url = 'http://bot'    # this is a local service
import requests

r = requests.get(url)

and I get

requests.exceptions.SSLError: HTTPSConnectionPool(host='bot', port=443)

I specified HTTP, not HTTPS, but it tried to connect with SSL.

So, I tried httplib2:

url = 'http://bot'    # this is a local service
response, content = http.request(url, "GET")

and I get:

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)

I don't know why there is an obsession with HTTPS, but I don't want it. it's a local service running in development and it is pure HTTP. Adding ":80" to the url doesn't change anything.

When using CURL or C# to access the same service, through HTTP, no problem.

How can I tell python libs that I want a pure HTTP connection and nothing else?

Thomas
  • 10,933
  • 14
  • 65
  • 136
  • Possible duplicate of [How do I disable the security certificate check in Python requests](https://stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests) – Piotr Kamoda Jul 19 '19 at 11:41
  • @Piotr, agreed; it's a duplicate – Thomas Jul 19 '19 at 11:43
  • 1
    It's a duplicate but when people don't know what a security certificate check is, they'll probably find this one, which will point to the right direction either way. – Roman Jul 19 '19 at 11:50
  • Roman has a point: I searched for a solution and since I didn't use the right terms, I couldn't find any; keeping this one open might help – Thomas Jul 19 '19 at 11:51

2 Answers2

5

Use requests library and add a ssl verify option. Your request line should look like this:

r = requests.get(url, verify = False)
Roman
  • 146
  • 5
  • It works! I don't understand why it tries to verify a HTTP scheme though – Thomas Jul 19 '19 at 11:50
  • @Thomas this is because your 'bot' has no SSL setup, and by default, `requests` always verifies SSL, so you need to tell it NO (verify = False) – Roman Jul 19 '19 at 11:53
1

Try to disable SSL_VERIFICATION

r = requests.get(url, verify = False)
Nishu Tayal
  • 20,106
  • 8
  • 49
  • 101