diff --git a/src/common/stanza_session.py b/src/common/stanza_session.py index e27c9b529..9b5b5ea63 100644 --- a/src/common/stanza_session.py +++ b/src/common/stanza_session.py @@ -584,7 +584,7 @@ class EncryptedStanzaSession(StanzaSession): self.status = 'responded-e2e' feature.addChild(node=x) - + if not_acceptable: response = xmpp.Error(response, xmpp.ERR_NOT_ACCEPTABLE) @@ -853,14 +853,29 @@ class EncryptedStanzaSession(StanzaSession): def acknowledge_termination(self): StanzaSession.acknowledge_termination(self) - + self.enable_encryption = False - def fail_bad_negotiation(self, reason): - '''they've tried to feed us a bogus value, send an error and cancel everything.''' + def fail_bad_negotiation(self, reason, fields = None): + '''sends an error and cancels everything. + +if fields == None, the remote party has given us a bad cryptographic value of some kind + +otherwise, list the fields we haven't implemented''' err = xmpp.Error(xmpp.Message(), xmpp.ERR_FEATURE_NOT_IMPLEMENTED) err.T.error.T.text.setData(reason) + + if fields: + feature = xmpp.Node(xmpp.NS_FEATURE + ' feature') + + for field in fields: + fn = xmpp.Node('field') + fn['var'] = field + feature.addChild(node=feature) + + err.addChild(node=feature) + self.send(err) self.status = None diff --git a/src/gajim.py b/src/gajim.py index f124a872f..6ca85d454 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1898,16 +1898,7 @@ class Interface: # we don't support 3-message negotiation as the responder if 'dhkeys' in form.asDict(): - err = xmpp.Error(xmpp.Message(), xmpp.ERR_FEATURE_NOT_IMPLEMENTED) - - feature = xmpp.Node(xmpp.NS_FEATURE + ' feature') - field = xmpp.Node('field') - field['var'] = 'dhkeys' - - feature.addChild(node=field) - err.addChild(node=feature) - - session.send(err) + session.fail_bad_negotiation('3 message negotiation not supported when responding', ('dhkeys',)) return negotiated, not_acceptable, ask_user = session.verify_options_bob(form)