summaryrefslogtreecommitdiff
path: root/sleekxmpp/xmlstream
diff options
context:
space:
mode:
authorFlorian Fieber <florian@florianfieber.de>2012-08-19 16:20:58 +0200
committerFlorian Fieber <florian@florianfieber.de>2012-08-19 16:40:22 +0200
commit09bec1c4fef78f9df021099d9b79d4f92c2af895 (patch)
tree9a1123010fc4fc65d648582ddf30da3d5079fe1f /sleekxmpp/xmlstream
parentff28b0a005410a2604b7b889e0347ae9d6a7efd9 (diff)
downloadslixmpp-09bec1c4fef78f9df021099d9b79d4f92c2af895.tar.gz
slixmpp-09bec1c4fef78f9df021099d9b79d4f92c2af895.tar.bz2
slixmpp-09bec1c4fef78f9df021099d9b79d4f92c2af895.tar.xz
slixmpp-09bec1c4fef78f9df021099d9b79d4f92c2af895.zip
Fix certificate expiration scheduler
timedelta.seconds does not store the total seconds of a time span. Internally, seconds is the next smaller unit to days, hence timedelta.seconds will never exceed (or reach) the number of seconds in a day (60*60*24=86400)
Diffstat (limited to 'sleekxmpp/xmlstream')
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index df06d067..246bc205 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -901,9 +901,15 @@ class XMLStream(object):
log.warn('CERT: Certificate has expired.')
restart()
+ try:
+ total_seconds = cert_ttl.total_seconds()
+ except AttributeError:
+ # for Python < 2.7
+ total_seconds = (cert_ttl.microseconds + (cert_ttl.seconds + cert_ttl.days * 24 * 3600) * 10**6) / 10**6
+
log.info('CERT: Time until certificate expiration: %s' % cert_ttl)
self.schedule('Certificate Expiration',
- cert_ttl.seconds,
+ total_seconds,
restart)
def _start_keepalive(self, event):