Search code examples
pythonpython-requestshttplib2

in Python, I want to do rest requests with HTTP and NOT with HTTPS, packages don't seem to agree


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?


Solution

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

    r = requests.get(url, verify = False)