Python Forum

Full Version: Requests not behaving...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

I've been trying to establish an http connection with requests. The problem is that I'm getting an ssl exceptions error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='www.thesite.org', port=443): Max retries exceeded with url: /?msg=login_err (Caused by SSLError(CertificateError("hostname 'www.thesite.org' doesn't match either of '*.webfaction.com', 'webfaction.com'",),))

So the ssl is improperly setup, so I'm not touching it. I've been trying to connect with http.

import requests

s = requests.session()

url = 'http://www.thesite.org/login.py'
data = {'username':'myusername', 'passwd':'mypassword'}
s.post(url, data)
s.get(url)
Is there any way to force the http connection?

So far I've tried verify=False... and I get a similar error about exceeding redirects.

Any ideas?

NVM

So if people come across this issue in the future, the answer is to specify the port in the URL.

so the above code will work with the line:

url = 'http://www.thesite.org/login.py:80'
Happy coding
Does that actually fix it, though?  Not all servers accept https connections on port 80, and your protocol is also http...
I'd sniff the network if I were you (on windows, that's easy with Fiddler) and verify that the connection is actually encrypted.