urllib2 EOF occurred in violation of protocol with proxy

B

Bloke

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?
 
P

Paul Rubin

Bloke said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top