escape from sslerror due to broken protocol
This commit is contained in:
parent
e3ba73be74
commit
873bedd221
2 changed files with 16 additions and 7 deletions
|
@ -127,11 +127,10 @@ class NBCommonClient(CommonClient):
|
||||||
def _on_connected(self):
|
def _on_connected(self):
|
||||||
self.connected = 'tcp'
|
self.connected = 'tcp'
|
||||||
if (self._Ssl is None and self.Connection.getPort() in (5223, 443)) or self._Ssl:
|
if (self._Ssl is None and self.Connection.getPort() in (5223, 443)) or self._Ssl:
|
||||||
try:
|
transports_nb.NonBlockingTLS().PlugIn(self, now=1)
|
||||||
transports_nb.NonBlockingTLS().PlugIn(self, now=1)
|
if not self.Connection: # ssl error, stream is closed
|
||||||
self.connected = 'ssl'
|
|
||||||
except socket.sslerror:
|
|
||||||
return
|
return
|
||||||
|
self.connected = 'ssl'
|
||||||
self.onreceive(self._on_receive_document_attrs)
|
self.onreceive(self._on_receive_document_attrs)
|
||||||
dispatcher_nb.Dispatcher().PlugIn(self)
|
dispatcher_nb.Dispatcher().PlugIn(self)
|
||||||
|
|
||||||
|
@ -194,6 +193,8 @@ class NonBlockingClient(NBCommonClient):
|
||||||
self.isplugged = True
|
self.isplugged = True
|
||||||
self.onreceive(None)
|
self.onreceive(None)
|
||||||
transports_nb.NonBlockingTLS().PlugIn(self)
|
transports_nb.NonBlockingTLS().PlugIn(self)
|
||||||
|
if not self.Connection: # ssl error, stream is closed
|
||||||
|
return True
|
||||||
if not self.Dispatcher.Stream._document_attrs.has_key('version') or \
|
if not self.Dispatcher.Stream._document_attrs.has_key('version') or \
|
||||||
not self.Dispatcher.Stream._document_attrs['version']=='1.0':
|
not self.Dispatcher.Stream._document_attrs['version']=='1.0':
|
||||||
self._is_connected()
|
self._is_connected()
|
||||||
|
|
|
@ -371,8 +371,12 @@ class NonBlockingTLS(PlugIn):
|
||||||
PlugIn.PlugIn(self, owner)
|
PlugIn.PlugIn(self, owner)
|
||||||
DBG_LINE='NonBlockingTLS'
|
DBG_LINE='NonBlockingTLS'
|
||||||
self.on_tls_start = on_tls_start
|
self.on_tls_start = on_tls_start
|
||||||
if now:
|
if now:
|
||||||
res = self._startSSL()
|
try:
|
||||||
|
res = self._startSSL()
|
||||||
|
except Exception, e:
|
||||||
|
self._owner.socket.pollend()
|
||||||
|
return
|
||||||
self.tls_start()
|
self.tls_start()
|
||||||
return res
|
return res
|
||||||
if self._owner.Dispatcher.Stream.features:
|
if self._owner.Dispatcher.Stream.features:
|
||||||
|
@ -434,7 +438,11 @@ class NonBlockingTLS(PlugIn):
|
||||||
self.DEBUG('Got starttls response: ' + self.starttls,'error')
|
self.DEBUG('Got starttls response: ' + self.starttls,'error')
|
||||||
return
|
return
|
||||||
self.DEBUG('Got starttls proceed response. Switching to TLS/SSL...','ok')
|
self.DEBUG('Got starttls proceed response. Switching to TLS/SSL...','ok')
|
||||||
self._startSSL()
|
try:
|
||||||
|
self._startSSL()
|
||||||
|
except Exception, e:
|
||||||
|
self._owner.socket.pollend()
|
||||||
|
return
|
||||||
self._owner.Dispatcher.PlugOut()
|
self._owner.Dispatcher.PlugOut()
|
||||||
dispatcher_nb.Dispatcher().PlugIn(self._owner)
|
dispatcher_nb.Dispatcher().PlugIn(self._owner)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue