Problem when applying Patch from issue1424152 to get https overauthenticating proxies working with u

T

tvashtar

Hi,
I'm trying to get https requests working through an authenticating
proxy with urllib2 in Python 2.5, I'm aware that this isn't supported
"out of the box", so applied the patch http://bugs.python.org/file9753/http-tunnel-urllib
linked from http://bugs.python.org/issue1424152 , my baseline test
program is the following:

p = "user:pass@proxy:port"
proxy_handler = urllib2.ProxyHandler({"http": p, "https": p})
urllib2.install_opener( urllib2.build_opener( urllib2.HTTPHandler,

urllib2.HTTPSHandler,

proxy_handler))

request = urllib2.Request( "https://groups.google.com")
response = urllib2.urlopen(request)

Unfortunately this doesn't work, the call stack being:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 374, in open
response = self._open(req, data)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 392, in _open
'_open', req)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 353, in _call_chain
result = func(*args)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 1108, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 1075, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error (1, 'error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown protocol')>

Does anyone know why I might be hitting this issue?
Any help is greatly appreciated,
thanks
 
N

Nike

Hi,
I'm trying to get https requests working through an authenticating
proxy with urllib2 in Python 2.5, I'm aware that this isn't supported
"out of the box", so applied the patchhttp://bugs.python.org/file9753/http-tunnel-urllib
linked fromhttp://bugs.python.org/issue1424152, my baseline test
program is the following:

p = "user:pass@proxy:port"
proxy_handler = urllib2.ProxyHandler({"http": p, "https": p})
urllib2.install_opener( urllib2.build_opener( urllib2.HTTPHandler,

urllib2.HTTPSHandler,

proxy_handler))

request = urllib2.Request( "https://groups.google.com")
response = urllib2.urlopen(request)

Unfortunately this doesn't work, the call stack being:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 121, in urlopen
    return _opener.open(url, data)
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 374, in open
    response = self._open(req, data)
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 392, in _open
    '_open', req)
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 353, in _call_chain
    result = func(*args)
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 1108, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\urllib2.py", line 1075, in do_open
    raise URLError(err)
urllib2.URLError: <urlopen error (1, 'error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown protocol')>

Does anyone know why I might be hitting this issue?
Any help is greatly appreciated,
thanks

hi!
It's looks like a ssl error . Under the following step to help u :
1. takes a simple code to confirm your pupose without ssl protocol.
2. to confirm python version and extended libs work well
3. to confirm ssl work well.

goog luck!

nikekoo
 
T

tvashtar

hi!
 It's looks like a ssl error . Under the following step to help u :
  1. takes a simple code to confirm your pupose without ssl protocol.
  2. to confirm python version and extended libs work well
  3. to confirm ssl work well.

goog luck!

nikekoo

I've reduced my code to the following:

import urllib2

p = "https://user:pass@myproxy:port"
proxy_handler = urllib2.ProxyHandler({"https": p})
urllib2.install_opener(urllib2.build_opener(proxy_handler))
request = urllib2.Request( "https://groups.google.com")
response = urllib2.urlopen(request)

and it is now failing with:

Traceback (most recent call last):
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\test.py", line 12, in <module>
response = urllib2.urlopen(request)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 379, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'_open', req)
File "C:\Python25\lib\urllib2.py", line 358, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1115, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python25\lib\urllib2.py", line 1082, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error Tunnel connection failed: 407 Proxy
Authentication Required>

I thought the proxy_handler should take care of the authentication?

Thanks for your help
 
H

harish.barvekar

I've reduced my code to the following:

import urllib2

p = "https://user:pass@myproxy:port"
proxy_handler = urllib2.ProxyHandler({"https": p})
urllib2.install_opener(urllib2.build_opener(proxy_handler))
request = urllib2.Request( "https://groups.google.com")
response = urllib2.urlopen(request)

and it is now failing with:

Traceback (most recent call last):
File "D:\p4\depot\Development\HEAD\Build\ReleaseSystem\DownloadSystem
\test.py", line 12, in <module>
response = urllib2.urlopen(request)
File "C:\Python25\lib\urllib2.py", line 121, in urlopen
return _opener.open(url, data)
File "C:\Python25\lib\urllib2.py", line 379, in open
response = self._open(req, data)
File "C:\Python25\lib\urllib2.py", line 397, in _open
'_open', req)
File "C:\Python25\lib\urllib2.py", line 358, in _call_chain
result = func(*args)
File "C:\Python25\lib\urllib2.py", line 1115, in https_open
return self.do_open(httplib.HTTPSConnection, req)
File "C:\Python25\lib\urllib2.py", line 1082, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error Tunnel connection failed: 407 Proxy
Authentication Required>

I thought the proxy_handler should take care of the authentication?

Thanks for your help

Is this issue fixed. I am also facing the same issue of tunneling in https request. Please suggest how to proceed further
 
C

Chris Angelico

Is this issue fixed. I am also facing the same issue of tunneling in https request. Please suggest how to proceed further

You're responding to something from 2009. It's highly likely things
have changed.

Does the same code cause an error in Python 2.7? That would be the
first thing to check.

Also: You appear to be using Google Groups, which is the Mos Eisley of
the newsgroup posting universe. You'll do far better to instead use
some other means of posting, such as the mailing list:

https://mail.python.org/mailman/listinfo/python-list

It's probably a good idea also to search the bug tracker before
posting. It may well be that this has been fixed, in which case the
tracker issue would tell you when the fix went out. Of course, it may
also state that it's not a bug, in which case you'd know why.

http://bugs.python.org/

ChrisA
 
M

Mark Lawrence

You're responding to something from 2009. It's highly likely things
have changed.

Says who? Sadly IMHO this has been one of the worst aspects of Python
development. I've seen 10 year old bugs happily sitting on the bug
tracker. Thankfully that is slowly changing. The core mentorship
program is helping, plus the gradual reduction in the number of versions
that need supporting as 2.6 is now out of support and we move towards
3.4. However there are still 4275 open issues on the bug tracker.
Anyone up to help out, the pay and perks are really good? :)
 
C

Chris Angelico

Says who? Sadly IMHO this has been one of the worst aspects of Python
development. I've seen 10 year old bugs happily sitting on the bug tracker.
Thankfully that is slowly changing. The core mentorship program is helping,
plus the gradual reduction in the number of versions that need supporting as
2.6 is now out of support and we move towards 3.4. However there are still
4275 open issues on the bug tracker. Anyone up to help out, the pay and
perks are really good? :)

There've been two minor versions since the version cited in the post
(2.5), not counting Python 3 at all. It's definitely worth rechecking
on 2.7 or 3.3, to see if the same still occurs. (Or, of course, to
read the tracker issue, which in this case was known and needn't be
searched for, a fact that I missed noticing when I went reading.) Yes,
four years' worth of bug fixes does make it at least somewhat likely
that something's changed.

ChrisA
 
M

Mark Lawrence

There've been two minor versions since the version cited in the post
(2.5), not counting Python 3 at all. It's definitely worth rechecking
on 2.7 or 3.3, to see if the same still occurs. (Or, of course, to
read the tracker issue, which in this case was known and needn't be
searched for, a fact that I missed noticing when I went reading.) Yes,
four years' worth of bug fixes does make it at least somewhat likely
that something's changed.

ChrisA

How many minor versions since this was created on 2002-01-16 at 04:56
http://bugs.python.org/issue504219 ? The issue originally referenced
is closed, this is still open. Age on the bug tracker is no guarantee
of anything, except that the issue exists.
 
R

rurpy

Also: You appear to be using Google Groups, which is the Mos Eisley of
the newsgroup posting universe. You'll do far better to instead use
some other means of posting, such as the mailing list:

Using Google Groups is also fine. I and many other posters here
use it. Chris and some others here dislike Google Groups and want
everyone to not use it, but that is their personal opinion.

If Google Groups is most convenient for you please feel free to
continue using it. You might want to take a look at this page
which describes how to reduce some of things that annoy people
like Chris:

https://wiki.python.org/moin/GoogleGroupsPython
 
M

Mark Lawrence

Using Google Groups is also fine. I and many other posters here
use it. Chris and some others here dislike Google Groups and want
everyone to not use it, but that is their personal opinion.

If Google Groups is most convenient for you please feel free to
continue using it. You might want to take a look at this page
which describes how to reduce some of things that annoy people
like Chris:

https://wiki.python.org/moin/GoogleGroupsPython

There is no "you might want to" about it. There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.
 
R

rusi

There is no "you might want to" about it. There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.

There are 10 kinds of people in the world: those who understand
binary and those who dont.
 
M

Mark Lawrence

There are 10 kinds of people in the world: those who understand
binary and those who dont.

There are 10 kinds of people in the world: those who understand that
google groups sends out double spaced crap and those who don't.
 
R

rurpy

On 10/12/2013 15:48, (e-mail address removed) wrote:
[...]
There is no "you might want to" about it. There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.

Mark is one of the resident trolls here. Among his other traits
is his delusion that he is Lord High Commander of this list.
Like with other trolls, the best advice is to ignore him (which
I'm not doing this once as a public service).
 
M

Mark Lawrence

On 10/12/2013 15:48, (e-mail address removed) wrote:
[...]
There is no "you might want to" about it. There are two options here,
either read and action the page so we don't see double spaced crap
amongst other things, use another tool, or don't post.

Mark is one of the resident trolls here. Among his other traits
is his delusion that he is Lord High Commander of this list.
Like with other trolls, the best advice is to ignore him (which
I'm not doing this once as a public service).

That is entirely correct. I also spend a lot of my time defending the
indefensible, like defending people who use crap tools to send double
spaced crap around the whole world. Not.
 
G

Grant Edwards

There are 10 kinds of people in the world: those who understand Gray
Code, those who don't, and those who confuse it with binary.

Let me pause and reflect on that for a moment...
 
D

David Robinow

On 12/10/2013 09:22 AM, Mark Lawrence wrote: ....
Mark is one of the resident trolls here. Among his other traits
is his delusion that he is Lord High Commander of this list.
Like with other trolls, the best advice is to ignore him (which
I'm not doing this once as a public service).
Please don't do this. I can decide for myself whether I prefer to read
Mark's posts.
[By the way, I don't consider Mark Lawrence a troll. He's just a guy
who can't help himself. I've chosen not to listen any more but others
are entitled to their own choices.]+
 
R

rurpy

Please don't do this. I can decide for myself whether I prefer to read
Mark's posts.

I didn't post it for you, I posted it for the OP who
may be new here (or may not, I didn't check) and for
others from Google Groups who may erroneously think
that Mark/Chris et.al. have some kind of authority or
speak for everyone here.

Nor was it a suggestion to not read Mark's posts but
a suggestion to not add to the flamage.
[By the way, I don't consider Mark Lawrence a troll. He's just a guy
who can't help himself. I've chosen not to listen any more but others
are entitled to their own choices.]+
 

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,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top