Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!fdn.fr!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'pypi': 0.07; 'socket': 0.07; '__init__': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; 'httplib': 0.16; 'ioerror:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'self.sock': 0.16; 'simplest': 0.16; 'skip:" 70': 0.16; 'subject:SSL': 0.16; 'underlying': 0.16; 'urllib': 0.16; 'extensions': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'trying': 0.19; 'help.': 0.21; 'machine': 0.22; '>>>': 0.22; 'import': 0.22; 'reset': 0.22; 'header:User-Agent:1': 0.23; 'ssl': 0.24; 'subject:problem': 0.24; 'fine': 0.24; 'supported': 0.26; 'header:X-Complaints-To:1': 0.27; 'idea': 0.28; 'url:bugs': 0.29; '(which': 0.31; 'requests': 0.31; '"",': 0.31; 'anyone': 0.31; 'file': 0.32; 'option': 0.32; 'open': 0.33; 'url:python': 0.33; '(most': 0.33; 'problem': 0.35; 'connection': 0.35; 'skip:s 30': 0.35; 'doing': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:microsoft': 0.37; 'server': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'more': 0.64; 'believe': 0.68; 'received:204': 0.75; 'article': 0.77; 'client- side': 0.84; 'curl': 0.84; 'received:204.14': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Deily Subject: Re: Weird SSL problem Date: Mon, 29 Sep 2014 15:55:57 -0700 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: 204.14.154.216 User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 80 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412031377 news.xs4all.nl 2867 [2001:888:2000:d::a6]:33760 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78475 In article , Roland Hedberg wrote: > Hi! > > Išm trying to access > https://stsadweb.one.microsoft.com/adfs/.well-known/openid-configuration > > Doing it the simplest way I get the following: > > >>> import urllib > >>> f = > >>> urllib.urlopen("https://stsadweb.one.microsoft.com/adfs/.well-known/openid > >>> -configuration") > Traceback (most recent call last): > File "", line 1, in > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", > line 87, in urlopen > return opener.open(url) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", > line 208, in open > return getattr(self, name)(url) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", > line 437, in open_https > h.endheaders(data) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py" > , line 969, in endheaders > self._send_output(message_body) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py" > , line 829, in _send_output > self.send(msg) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py" > , line 791, in send > self.connect() > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py" > , line 1176, in connect > self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", > line 387, in wrap_socket > ciphers=ciphers) > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", > line 143, in __init__ > self.do_handshake() > File > "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", > line 305, in do_handshake > self._sslobj.do_handshake() > IOError: [Errno socket error] [Errno 54] Connection reset by peer > >>> import ssl > >>> ssl.OPENSSL_VERSION > šOpenSSL 0.9.8za 5 Jun 2014' > > Now, using Safari, or curl for that matter, from the same machine works > without a hitch. > > The URL above is also the only URL Išve encountered this problem with. > > Anyone got an idea ? I believe the problem is that the connection is protected by a multi-hostname server certificate and Python 2's urllib (and underlying httplib and ssl modules) do not support SNI extensions to TLS. The request above works fine with Python 3 (which has supported client-side SNI since Python 3.2). See http://bugs.python.org/issue5639 for more discussion of the matter. If Python 3 is not an option for you, the requests package available via PyPI should help. -- Ned Deily, nad@acm.org