which.linden  committed 793b676

[svn r142] Fix for EVT-4: eventlet's https client is unable to communicate with it's https server. This turned out to be a combination of two factors: 1) the ssl server wasn't properly shutting down its socket before closing it, and 2) the client wasn't properly ignoring the error that this condition generates.

  • Participants
  • Parent commits 7f4313b
  • Branches trunk

Comments (0)

Files changed (3)

File eventlet/

-    def dont_test_connect_ssl(self):
-        """ This test is broken, please fix it, remove the dont from the 
-        name and remove this comment"""
+    def test_connect_ssl(self):
         def accept_once(listenfd):
                 conn, addr = listenfd.accept()
         connected = []
         def accept_twice((conn, addr)):
-            print 'connected'
             if len(connected) == 2:

File eventlet/

     from OpenSSL import SSL
     from eventlet import wrappedfd, util
     context = SSL.Context(SSL.SSLv23_METHOD)
-    print certificate, private_key
     if certificate is not None:
     if private_key is not None:
     except SSL.SysCallError, e:
         (ssl_errno, ssl_errstr) = e
         if ssl_errno == -1 or ssl_errno > 0:
-            raise socket.error(errno.ECONNRESET, errno.errorcode[errno.ECONNRESET])
+            return ''
 def file_recv(fd, buflen):

File eventlet/

         fn = self.setblocking = self.fd.setblocking
         return fn(*args, **kw)
+    def shutdown(self, *args, **kw):
+        if self.is_secure:
+            fn = self.shutdown = self.fd.sock_shutdown
+        else:
+            fn = self.shutdown = self.fd.shutdown
+        return fn(*args, **kw)
     def close(self, *args, **kw):
         if self._closed:
         if self._refcount.is_referenced():
         self._closed = True
+        if self.is_secure:
+            # *NOTE: This is not quite the correct SSL shutdown sequence.
+            # We should actually be checking the return value of shutdown.
+            # Note also that this is not the same as calling self.shutdown().
+            self.fd.shutdown()
         fn = self.close = self.fd.close
             res = fn(*args, **kw)