468,104 Members | 1,312 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,104 developers. It's quick & easy.

urllib2 not support proxy on SSL connection?

Hi,

I am running the following simple code (just open connection to some
https page with proxy):

proxy= '666.179.227.666:80'
proxy=urllib2.ProxyHandler({"https":'https://'+proxy})
opener = urllib2.build_opener(proxy)
request = urllib2.Request('https://somehttpspage....')
response = opener.open(request)

And I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\lib\urllib2.py", line 358, in open
response = self._open(req, data)
File "C:\Python24\lib\urllib2.py", line 376, in _open
'_open', req)
File "C:\Python24\lib\urllib2.py", line 337, in _call_chain
result = func(*args)
File "C:\Python24\lib\urllib2.py", line 1029, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python24\lib\urllib2.py", line 996, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error (1, 'error:140770FC:SSL
routines:SSL23_GET_SERV
ER_HELLO:unknown protocol')>

Is it possible that urllib2 doesnt support for proxy over https
connections?

Thanks alot,
Itay.

May 2 '06 #1
3 2847
Am Dienstag 02 Mai 2006 23:22 schrieb itay_k:
Is it possible that urllib2 doesnt support for proxy over https
connections?


Are you sure this a proxy which is accessed by https, or rather a proxy that
supports CONNECT, and thus allows you to access https-sites? I'd guess the
latter, which I haven't gotten to work with urllib2 so far.

AFAICT, that's why you get an unknown protocol error from the SSL library,
because the proxy starts a plaintext session, and urllib2 expects an SSL
session (which you try to use to access the proxy, because you specify https
as the proxy URL), and so doesn't know what to do with the data it gets.

I'd guess you'd have to rethink what you're doing here...

--- Heiko.
May 2 '06 #2
Heiko Wundram <me*******@modelnine.org> writes:
Am Dienstag 02 Mai 2006 23:22 schrieb itay_k:
Is it possible that urllib2 doesnt support for proxy over https
connections?


Are you sure this a proxy which is accessed by https, or rather a proxy that
supports CONNECT, and thus allows you to access https-sites? I'd guess the
latter, which I haven't gotten to work with urllib2 so far.

[...]

There's a patch on SF that implements this (CONNECT), but it's fairly
nasty and would need rewriting to get into the stdlib.
John

May 3 '06 #3
Heiko Wundram <me*******@modelnine.org> writes:
Am Dienstag 02 Mai 2006 23:22 schrieb itay_k:
Is it possible that urllib2 doesnt support for proxy over https
connections?


Are you sure this a proxy which is accessed by https, or rather a proxy that
supports CONNECT, and thus allows you to access https-sites? I'd guess the
latter, which I haven't gotten to work with urllib2 so far.


Also a recipe (maybe essentially the same as the SF patch, don't
remember):

http://aspn.activestate.com/ASPN/Coo.../Recipe/456195
John

May 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by O. Koch | last post: by
4 posts views Thread by bmiras | last post: by
reply views Thread by Lee, Dustin | last post: by
reply views Thread by Carl Waldbieser | last post: by
1 post views Thread by tomazi75-nospam(at)gmail.com | last post: by
6 posts views Thread by Alejandro Dubrovsky | last post: by
reply views Thread by Ali.Sabil | last post: by
4 posts views Thread by looping | last post: by
reply views Thread by Astan Chee | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.