New submission from Isaac Salsberg <isalsb...@users.sourceforge.net>:
https connections fails under intel MAC OS X 10.6.6 and 10.6.7 using httplib and/or urllib2 connecting to an IIS web server requesting basic authentication and a client certificate. This is an issue with MAC OS X 10.6.x, because I tried these very same scripts under RHES 5 x64 with python 2.6.5 and python 2.7.1 and they both run just fine. ---------------------------- Sample code with urllib2: import urllib2 response = urllib2.urlopen('https://www.finratrace.org/') ------------------ Sample code with httplib import httplib,base64 key,cert=('/tmp/cert_nopwd.pem',)*2 HOSTNAME = 'www.finratrace.org' username,password='myuser','mypass' base64string = base64.encodestring('%s:%s' % (username, password))[:-1] conn = httplib.HTTPSConnection(HOSTNAME,key_file = key,cert_file = cert) conn.putrequest('GET', '/') conn.putheader("Authorization", "Basic %s" % base64string) conn.endheaders() response = conn.getresponse() ----------------------- Both samples send the following error: ====>With python 2.6.1 Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import urllib2 >>> response = urllib2.urlopen('https://www.finratrace.org/') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 124, in urlopen return _opener.open(url, data, timeout) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 383, in open response = self._open(req, data) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 401, in _open '_open', req) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain result = func(*args) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 1138, in https_open return self.do_open(httplib.HTTPSConnection, req) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 1103, in do_open r = h.getresponse() File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 950, in getresponse response.begin() File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 390, in begin version, status, reason = self._read_status() File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 354, in _read_status raise BadStatusLine(line) httplib.BadStatusLine ================================== ====>Same thing happens Using python 2.7.1 Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import httplib,base64 >>> >>> key,cert=('/tmp/cert_nopwd.pem',)*2 >>> HOSTNAME = 'www.finratrace.org' >>> >>> username,password='myuser','mypass' >>> >>> base64string = base64.encodestring('%s:%s' % (username, password))[:-1] >>> >>> >>> conn = httplib.HTTPSConnection(HOSTNAME,key_file = key,cert_file = cert) >>> conn.putrequest('GET', '/') >>> conn.putheader("Authorization", "Basic %s" % base64string) >>> >>> conn.endheaders() >>> response = conn.getresponse() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1021, in getresponse return response File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 401, in begin while True: File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 365, in _read_status # sending a valid response. httplib.BadStatusLine: '' ===================================== I also compiled py 2.7 getting the same error message. I tried patches from Issue7291, but did not work. ---------- assignee: ronaldoussoren components: Library (Lib), Macintosh messages: 132636 nosy: isalsberg, ronaldoussoren priority: normal severity: normal status: open title: httplib and urllib2 failed ssl connection httplib.BadStatusLine type: resource usage versions: Python 2.6, Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11725> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com