SSL connection issue with Windows CPython

Discussion in 'Python' started by Blairo, Dec 4, 2011.

  1. Blairo

    Blairo Guest

    Hi all,

    I've written a Python API for the Windows Azure Service Management web-
    service. Requests against the web-service are HTTPS with a client
    certificate used for authentication. This works fine with CPython
    (tested with 2.6 and 2.7) on Linux, but something is amiss with the
    SSL connection with vanilla python.org CPython (again 2.6 and 2.7) on
    Windows. I've managed to boil it down to a simple test case, which
    should return a list of Azure data-centre locations (requires an Azure
    account):
    --------------------
    Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit
    (AMD64)] on win32
    Type "copyright", "credits" or "license()" for more information.
    >>> sub_id = '506...-...-...-...-...'
    >>> cert = 'c:\\users\\blair\\...\\azure.pem'
    >>> import socket,ssl
    >>> s = ssl.wrap_socket(socket.socket(), certfile=cert)
    >>> s.connect(('management.core.windows.net',443))
    >>> s.send("GET /%s/locations HTTP/1.1\r\nAccept-Encoding: identity\r\nX-Ms-Version: 2011-10-01\r\nHost: management.core.windows.net\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n" % sub_id)

    202
    >>> s.read(2048)


    Traceback (most recent call last):
    File "<pyshell#8>", line 1, in <module>
    s.read(2048)
    File "C:\Python27\lib\ssl.py", line 138, in read
    return self._sslobj.read(len)
    error: [Errno 10054] An existing connection was forcibly closed by the
    remote host
    --------------------

    What's interesting is that the exact same code works with ActivePython
    (2.6 and 2.7), output omitted here for brevity. There is more detail
    on a (currently unanswered) stackoverflow post:
    http://stackoverflow.com/questions/...azure-service-management-api-fails-on-windows
    ..

    I'm not sure where/what the difference is. My best guess so far is
    that ActivePython bundles a newer version of OpenSSL then the
    python.org version and that the problem must be there. Any further
    insight would be appreciated.

    TIA,
    ~Blair
     
    Blairo, Dec 4, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 620
    Replies:
    2
    Views:
    1,059
    Murat Tunaboylu
    Jan 6, 2004
  2. CW
    Replies:
    2
    Views:
    561
  3. Alf P. Steinbach

    How to crash CPython 3.1.1 in Windows XP

    Alf P. Steinbach, Mar 1, 2010, in forum: Python
    Replies:
    0
    Views:
    286
    Alf P. Steinbach
    Mar 1, 2010
  4. Silviu Tudoras

    Moving from an SSL to an non-SSL connection

    Silviu Tudoras, Jul 25, 2003, in forum: ASP .Net Security
    Replies:
    1
    Views:
    149
    Michal A. Valasek
    Jul 25, 2003
  5. Jason Friedman
    Replies:
    0
    Views:
    164
    Jason Friedman
    Dec 27, 2012
Loading...

Share This Page