Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > SSL connection issue with Windows CPython

Reply
Thread Tools

SSL connection issue with Windows CPython

 
 
Blairo
Guest
Posts: n/a
 
      12-04-2011
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(204


Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
s.read(204
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/8...ils-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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ImportError: /usr/local/lib/python3.2/dist-packages/OpenSSL/SSL.cpython-32mu.so: Jason Friedman Python 0 12-27-2012 03:47 PM
How to crash CPython 3.1.1 in Windows XP Alf P. Steinbach Python 0 03-01-2010 09:16 PM
Compiling a CPython library on Mac OSX Boris Boutillier Python 3 12-12-2003 05:49 PM
Same GUI in both CPython and Jython? York Python 1 09-10-2003 06:25 PM
Moving from an SSL to an non-SSL connection Silviu Tudoras ASP .Net Security 1 07-25-2003 10:15 PM



Advertisments