summaryrefslogtreecommitdiff
path: root/sleekxmpp/features/feature_starttls
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2011-07-02 22:30:34 -0700
committerLance Stout <lancestout@gmail.com>2011-07-02 22:30:55 -0700
commitb898b14b77d739cb1c118c9e3648aa268348d293 (patch)
treef57d3675b65b5338d9f260629faa03be953fc9fe /sleekxmpp/features/feature_starttls
parentfba235a801a3a1c06d1769cdc944b72dce33f88a (diff)
downloadslixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.tar.gz
slixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.tar.bz2
slixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.tar.xz
slixmpp-b898b14b77d739cb1c118c9e3648aa268348d293.zip
Use a set to track negotiated features.
Added guards to prevent renegotiating STARTTLS or SASL in cases where servers don't behave properly.
Diffstat (limited to 'sleekxmpp/features/feature_starttls')
-rw-r--r--sleekxmpp/features/feature_starttls/starttls.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/sleekxmpp/features/feature_starttls/starttls.py b/sleekxmpp/features/feature_starttls/starttls.py
index cbb94be0..841e7a8d 100644
--- a/sleekxmpp/features/feature_starttls/starttls.py
+++ b/sleekxmpp/features/feature_starttls/starttls.py
@@ -48,7 +48,11 @@ class feature_starttls(base_plugin):
Arguments:
features -- The stream:features element.
"""
- if not self.xmpp.use_tls:
+ if 'starttls' in self.xmpp.features:
+ # We have already negotiated TLS, but the server is
+ # offering it again, against spec.
+ return False
+ elif not self.xmpp.use_tls:
return False
elif self.xmpp.ssl_support:
self.xmpp.send(features['starttls'], now=True)
@@ -62,5 +66,5 @@ class feature_starttls(base_plugin):
"""Restart the XML stream when TLS is accepted."""
log.debug("Starting TLS")
if self.xmpp.start_tls():
- self.xmpp.features.append('starttls')
+ self.xmpp.features.add('starttls')
raise RestartStream()