Velocity Reviews - Computer Hardware Reviews

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

Thread Tools

SSL connection issue with Windows CPython

Posts: n/a
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 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
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(('',443))
>>> s.send("GET /%s/locations HTTP/1.1\r\nAccept-Encoding: identity\r\nX-Ms-Version: 2011-10-01\r\nHost:\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\n" % sub_id)


Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
File "C:\Python27\lib\", line 138, in read
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:

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 version and that the problem must be there. Any further
insight would be appreciated.

Reply With Quote

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/ 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