SSL (HTTPS) with 2.4

Bloke rhall at thiess.com.au
Wed May 18 02:14:39 EDT 2005


Thanks Martin.  That means my code should work.

I am trying to go through a proxy, which works fine for HTTP sites.
However, when I try a HTTPS site, the program doesn't respond for quite
a while, and returns the error:

"  File "C:\Python24\lib\urllib2.py", line 996, in do_open
    raise URLError(err)
URLError: <urlopen error (8, 'EOF occurred in violation of protocol')>"

Here is my testing code:

import urllib2

proxy_info = {
    'user' : 'me',
    'pass' : 'mypassword',
    'host' : 'proxy.mycompany.com',
    'port' : 8008 }  # settings taken from web browser


# 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.directshares.com.au')
print f.headers 
f.close()

Any ideas what is wrong?

Bloke




More information about the Python-list mailing list