By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

urllib2 EOF occurred in violation of protocol with proxy

P: n/a
I want to connect to a https server through an authenticating proxy
like this:

import urllib2

proxy_info = {
'user' : 'me',
'pass' : 'password',
'host' : 'mycompany.com.au',
'port' : 8008 }

# build a new opener that uses a proxy requiring authorization
proxy_support = urllib2.ProxyHandler({"https":"https://%(user)s:%
(pass)s@%(host)s:%(port)d" % proxy_info})

opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)

# install it
urllib2.install_opener(opener)

# use it
f = urllib2.urlopen('https://www.securewebsite.com.au')
print f.headers
print f.read()
f.close()

If I modify the 'https' to 'http' it works fine. But in https mode it
returns:

URLError: <urlopen error (8, 'EOF occurred in violation of protocol')>

The site works fine if I do not go through the proxy, so it appears the
proxy is not returning an EOF. I been searching for an answer, and
found many other sites where people have had the same problem. Some
have suggested m2crypto.

Is there a work around using the standard 2.4.1 installation?

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Bloke" <rh***@thiess.com.au> writes:
The site works fine if I do not go through the proxy, so it appears the
proxy is not returning an EOF. I been searching for an answer, and
found many other sites where people have had the same problem. Some
have suggested m2crypto.

Is there a work around using the standard 2.4.1 installation?


I sort of remember some problem like that with Microsoft web servers.
It's not clear that a "workaround" is really the right thing--it's a
security hole, it lets attackers truncate web pages coming through the
proxy without your client app being able to tell the difference.

OpenSSL includes an interactive SSL client (sort of like telnet) that
can be convenient for trying stuff out without having to write code.
Just type for example at the openssl prompt:

OpenSSL> s_client -connect www.yourhost.com 443
GET / HTTP/1.0
<newline>
<newline>

substituting whatever your host and port are.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.