So, I&#39;m not sure if anyone is interested, but I patched stacklesssocket to support TLSLite, and it seems to be working. It uses the normal<br>socket.ssl() interface.<br><br>Arnar: passing a stacklesssocket to socket.ssl
() didn&#39;t work, since socket.ssl wraps a socket with a blocking interface from _ssl.c.<br><br>Stacklesssocket likes to be on top ;-)<br><br>I just gave stacklesssocket a ssl() function which replaces the default dispatcher with one inheriting the 
tlslite.integration.TLSAsyncDispatcherMixin.<br>I wish I wasn&#39;t instantiating a dispatcher, killing it, and instantiating another for every tls connection, but it was a quick way to get urllib (and therefore, <a href="http://code.google.com/p/boto/">
boto</a>) to work. This little inefficiency can be avoided, of course, with a little more effort, i.e. building it by hand, instead of using ssl().<br><br>___Here are the additions:________________________________________________________
<br><br># TLSLite Optional<br>try:<br>&nbsp;&nbsp;&nbsp; from tlslite.api import *<br>&nbsp;&nbsp;&nbsp; tls_enabled = True<br>except ImportError:<br>&nbsp;&nbsp;&nbsp; tls_enabled = False<br><br>#<br># Replace a stacklessocket&#39;s dispatcher with one inheriting <br>
# tlslite.integration.TLSDispatcherMixIn<br>#<br>def ssl(sock, keyfile=None, certfile=None):<br>&nbsp;&nbsp;&nbsp; if tls_enabled:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sock.dispatcher = TLSDispatcher(self.sock, keyfile, certfile)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return sock<br>&nbsp;&nbsp;&nbsp; else:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;SSL Support requires TLSLite!&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return None<br><br><br>#<br># Adds TLSAsyncDispatcherMixIn methods to the stacklesssocket dispatcher.<br>#<br>class TLSDispatcher(TLSAsyncDispatcherMixIn, dispatcher):
<br>&nbsp;&nbsp;&nbsp; def __init__(self, sock, keyfile, certfile):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dispatcher.__init__(self, sock)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TLSAsyncDispatcherMixIn.__init__(self, sock)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Do I want this?<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.tlsConnection.ignoreAbruptClose
 = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if keyfile and certfile:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x509 = X509()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; key = file(keyfile).read()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cert = file(certfile).read()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x509.parse(cert)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; certChain = X509CertChain([x509])
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; privateKey = parsePEMKey(key, private=True)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.setHandshakeOp(handshakeClientCert(certChain=certChain,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; privateKey=privateKey,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; async=True))
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.setHandshakeOp(handshakeClientUnknown(async=True))<br>________________________________________________________________________________<br><br>____Here&#39;s a test script:________________________________________________________
<br><br>import sys<br>import stacklesssocket<br>import stackless<br><br>sys.modules[&quot;socket&quot;] = stacklesssocket<br><br>import urllib<br>import time<br><br>url = &quot;<a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">
https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi</a>&quot;<br><br>def download(uri):<br>&nbsp;&nbsp;&nbsp;&nbsp; t1 = time.time()<br>&nbsp;&nbsp;&nbsp;&nbsp; f = urllib.urlopen(uri)<br>&nbsp;&nbsp;&nbsp;&nbsp; s = f.read()<br>&nbsp;&nbsp;&nbsp;&nbsp; t2 = time.time
()<br>&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Downloaded&quot;, uri, &quot;in&quot;, &quot;%.1f&quot; % (t2-t1), &quot;seconds&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp; return t2-t1<br><br><br>print &quot; === Serial === &quot;<br><br>t1 = time.time()<br><br>for d in xrange(10):
<br>&nbsp;&nbsp;&nbsp; download(url)<br><br>t2 = time.time()<br>print &quot; ---&gt;&quot;, t2-t1<br><br><br>print &quot; === Parallel === &quot;<br><br>for d in xrange(10):<br>&nbsp;&nbsp;&nbsp; stackless.tasklet(download)(url)<br><br>t1 = time.time()
<br><br>stackless.run()<br><br>t2 = time.time()<br>print &quot; ---&gt;&quot;, t2-t1<br><br>______________________________________________________________________<br><br>root@domU-12-31-36-00-2D-01:/usr/local/legion# stackless ssl_test.py
<br>&nbsp;=== Serial === <br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.5 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.7 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.1 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.0 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.7 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.9 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.3 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.5 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.6 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.3 seconds<br>&nbsp;---&gt; 10.5861570835<br>&nbsp;=== Parallel === <br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.7 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.6 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.4 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.6 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.1 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.0 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 0.7 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.0 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.2 seconds<br>Downloaded <a href="https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi">https://addons.mozilla.org/en-US/firefox/downloads/file/16347/web_developer-1.1.4-fx+fl.xpi
</a> in 1.4 seconds<br>&nbsp;---&gt; 8.78113698959<br><br>______________________________________________________________________________________________________________<br><br>I also tested X509 Certificate Authentication (with boto, which also uses urllib).
<br><br>It works on my cloud.<br><br>Much Respect,<br>Phoenix Sol<br>